Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
3b315088
Commit
3b315088
authored
Aug 14, 2008
by
Jon Skeet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimisations of IsInitialized and removal of unnecessary references.
parent
0677933d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
5 deletions
+41
-5
ProtocolBuffers.Test.csproj
csharp/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj
+0
-2
ExtendableMessage.cs
csharp/ProtocolBuffers/ExtendableMessage.cs
+7
-1
GeneratedMessage.cs
csharp/ProtocolBuffers/GeneratedMessage.cs
+34
-0
ProtocolBuffers.csproj
csharp/ProtocolBuffers/ProtocolBuffers.csproj
+0
-2
No files found.
csharp/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj
View file @
3b315088
...
@@ -42,8 +42,6 @@
...
@@ -42,8 +42,6 @@
<HintPath>
lib\Rhino.Mocks.dll
</HintPath>
<HintPath>
lib\Rhino.Mocks.dll
</HintPath>
</Reference>
</Reference>
<Reference
Include=
"System"
/>
<Reference
Include=
"System"
/>
<Reference
Include=
"System.Data"
/>
<Reference
Include=
"System.Xml"
/>
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<Compile
Include=
"AbstractMessageTest.cs"
/>
<Compile
Include=
"AbstractMessageTest.cs"
/>
...
...
csharp/ProtocolBuffers/ExtendableMessage.cs
View file @
3b315088
...
@@ -67,12 +67,18 @@ namespace Google.ProtocolBuffers {
...
@@ -67,12 +67,18 @@ namespace Google.ProtocolBuffers {
}
}
/// <summary>
/// <summary>
/// Called
by subclasses
to check if all extensions are initialized.
/// Called to check if all extensions are initialized.
/// </summary>
/// </summary>
protected
bool
ExtensionsAreInitialized
{
protected
bool
ExtensionsAreInitialized
{
get
{
return
extensions
.
IsInitialized
;
}
get
{
return
extensions
.
IsInitialized
;
}
}
}
public
override
bool
IsInitialized
{
get
{
return
base
.
IsInitialized
&&
ExtensionsAreInitialized
;
}
}
#
region
Reflection
#
region
Reflection
public
override
IDictionary
<
FieldDescriptor
,
object
>
AllFields
{
public
override
IDictionary
<
FieldDescriptor
,
object
>
AllFields
{
get
{
get
{
...
...
csharp/ProtocolBuffers/GeneratedMessage.cs
View file @
3b315088
...
@@ -18,6 +18,7 @@ using System.Collections.Generic;
...
@@ -18,6 +18,7 @@ using System.Collections.Generic;
using
Google.ProtocolBuffers.Collections
;
using
Google.ProtocolBuffers.Collections
;
using
Google.ProtocolBuffers.Descriptors
;
using
Google.ProtocolBuffers.Descriptors
;
using
Google.ProtocolBuffers.FieldAccess
;
using
Google.ProtocolBuffers.FieldAccess
;
using
System.Collections
;
namespace
Google.ProtocolBuffers
{
namespace
Google.ProtocolBuffers
{
...
@@ -60,6 +61,39 @@ namespace Google.ProtocolBuffers {
...
@@ -60,6 +61,39 @@ namespace Google.ProtocolBuffers {
return
ret
;
return
ret
;
}
}
public
override
bool
IsInitialized
{
get
{
// Check that all required fields are present.
foreach
(
FieldDescriptor
field
in
DescriptorForType
.
Fields
)
{
if
(
field
.
IsRequired
&&
!
HasField
(
field
))
{
return
false
;
}
}
// Check that embedded messages are initialized.
// This code is similar to that in AbstractMessage, but we don't
// fetch all the field values - just the ones we need to.
foreach
(
FieldDescriptor
field
in
DescriptorForType
.
Fields
)
{
if
(
field
.
MappedType
==
MappedType
.
Message
)
{
if
(
field
.
IsRepeated
)
{
// We know it's an IList<T>, but not the exact type - so
// IEnumerable is the best we can do. (C# generics aren't covariant yet.)
foreach
(
IMessage
element
in
(
IEnumerable
)
this
[
field
])
{
if
(!
element
.
IsInitialized
)
{
return
false
;
}
}
}
else
{
if
(!((
IMessage
)
this
[
field
]).
IsInitialized
)
{
return
false
;
}
}
}
}
return
true
;
}
}
public
override
IDictionary
<
FieldDescriptor
,
object
>
AllFields
{
public
override
IDictionary
<
FieldDescriptor
,
object
>
AllFields
{
get
{
return
Dictionaries
.
AsReadOnly
(
GetMutableFieldMap
());
}
get
{
return
Dictionaries
.
AsReadOnly
(
GetMutableFieldMap
());
}
}
}
...
...
csharp/ProtocolBuffers/ProtocolBuffers.csproj
View file @
3b315088
...
@@ -34,8 +34,6 @@
...
@@ -34,8 +34,6 @@
</PropertyGroup>
</PropertyGroup>
<ItemGroup>
<ItemGroup>
<Reference
Include=
"System"
/>
<Reference
Include=
"System"
/>
<Reference
Include=
"System.Data"
/>
<Reference
Include=
"System.Xml"
/>
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<Compile
Include=
"AbstractBuilder.cs"
/>
<Compile
Include=
"AbstractBuilder.cs"
/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment