当前位置: 首页>>代码示例>>C#>>正文


C# FieldDescriptor类代码示例

本文整理汇总了C#中FieldDescriptor的典型用法代码示例。如果您正苦于以下问题:C# FieldDescriptor类的具体用法?C# FieldDescriptor怎么用?C# FieldDescriptor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FieldDescriptor类属于命名空间,在下文中一共展示了FieldDescriptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IsSerializable

        private static bool IsSerializable(FieldDescriptor fd, object obj)
        {
            switch (fd.FdType)
            {
                case FieldTypes.Scalar:
                    if (fd.IsDefaultValueFromContext(obj))
                        return false;
                    break;
                case FieldTypes.CompositeElement:
                case FieldTypes.CollectionElement:
                case FieldTypes.MapElement:
                    Object tempObj = fd.GetObject(obj);
                    if (tempObj == null)
                        return false;
                    break;
                case FieldTypes.CollectionScalar:
                case FieldTypes.MapScalar:
                    Object scalarCollectionObject = fd.GetObject(obj);
                    if (scalarCollectionObject == null)
                        return false;
                    ICollection scalarCollection = XmlTools.GetCollection(scalarCollectionObject);
                    if (scalarCollection == null || scalarCollection.Count <= 0)
                        return false;
                    break;
            }

            return true;
        }
开发者ID:ecologylab,项目名称:simplCSharp,代码行数:28,代码来源:JsonSerializer.cs

示例2: equals

 public bool equals(FieldDescriptor fd) 
 { 
     return fieldName.Equals(fd.fieldName) 
         && className.Equals(fd.className)
         && valueDesc == fd.valueDesc
         && type == fd.type;
 }
开发者ID:yan122725529,项目名称:TripRobot.Crawler,代码行数:7,代码来源:ClassDescriptor.cs

示例3: ExtensionGenerator

 internal ExtensionGenerator(FieldDescriptor descriptor)
     : base(descriptor, 0)
 {
     if (Descriptor.ExtensionScope != null)
     {
         scope = GetClassName(Descriptor.ExtensionScope);
     }
     else
     {
         scope = DescriptorUtil.GetFullUmbrellaClassName(Descriptor.File);
     }
     switch (Descriptor.MappedType)
     {
         case MappedType.Message:
             type = GetClassName(Descriptor.MessageType);
             break;
         case MappedType.Enum:
             type = GetClassName(Descriptor.EnumType);
             break;
         default:
             type = DescriptorUtil.GetMappedTypeName(Descriptor.MappedType);
             break;
     }
     extends = GetClassName(Descriptor.ContainingType);
     name = Descriptor.CSharpOptions.PropertyName;
 }
开发者ID:ZhouX1ang,项目名称:protobuf-csharp-port,代码行数:26,代码来源:ExtensionGenerator.cs

示例4: Get

		public override void Get(FieldDescriptor ds_, IDataReader dr_)
		{
			switch( ds_.Pos )
			{
				case 0: Name = dr_.AsString(); break;
				case 1: dr_.AsMessage(_data??(Data = new Struct()), ds_); break;
			}
		}
开发者ID:Dataflow-Software,项目名称:Dataflow.NET,代码行数:8,代码来源:BuiltInTypes.pb.cs

示例5: LoadFields

 public override void LoadFields(FieldDescriptor[] fields)
 {
     base.LoadFields(fields); // removes RequiredMessageHeader
     if (Fields.Length != 3 ||
         Fields[0].Type.Name != "DT_INT" ||
         Fields[1].Type.Name != "DT_FIXEDARRAY" || Fields[1].SubType.Name != "NetAttributeKeyValue" ||
         Fields[2].Type != null)
         throw new Exception("Unexpected fields in AttributesSetValuesMessage.");
 }
开发者ID:rotacioskapa,项目名称:mooege,代码行数:9,代码来源:AttributesSetValuesMessage.cs

示例6: LoadFields

        public override void LoadFields(FieldDescriptor[] fields)
        {
            base.LoadFields(fields); // removes RequiredMessageHeader

            if (Fields.Length != 2 ||
                Fields[0].Type.Name != "DT_INT" || Fields[0].HasMinMax != false && Fields[0].EncodedBits != 32 ||
                Fields[1].Type != null)
                throw new Exception("Unexpected fields in GenericBlobMessage");
        }
开发者ID:rotacioskapa,项目名称:mooege,代码行数:9,代码来源:GenericBlobMessage.cs

示例7: LoadFields

 public override void LoadFields(FieldDescriptor[] fields)
 {
     base.LoadFields(fields); // removes RequiredMessageHeader
     if (this.Fields.Length != 4 ||
         this.Fields[0].Type._Name != "RequiredMessageHeader" ||
         this.Fields[1].Type._Name != "DT_INT" ||
         this.Fields[2].Type._Name != "NetAttributeKeyValue" ||
         this.Fields[3].Type != null)
         throw new Exception("Unexpected fields in AttributeSetValueMessage");
 }
开发者ID:starcasters,项目名称:type-extractor,代码行数:10,代码来源:AttributeSetValueMessage.cs

示例8: SerializeComposite

        /// <summary>
        /// 
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="textWriter"></param>
        /// <param name="translationContext"></param>
        /// <param name="fd"></param>
        private void SerializeComposite(object obj, TextWriter textWriter, TranslationContext translationContext,
            FieldDescriptor fd)
        {
            Object compositeObject = fd.GetObject(obj);
            FieldDescriptor compositeAsScalarFd = GetClassDescriptor(compositeObject).ScalarValueFieldDescripotor;

            if (compositeAsScalarFd != null)
            {
                WriteBibtexAttribute(compositeObject, fd, textWriter, translationContext);
            }
        }
开发者ID:ecologylab,项目名称:simplCSharp,代码行数:18,代码来源:BibtexSerializer.cs

示例9: CheckedMungeValue

 /// <summary>
 /// Munges a single value and checks that the length ends up the same as it was before.
 /// </summary>
 private static object CheckedMungeValue(FieldDescriptor fieldDescriptor, object value)
 {
     int currentSize = CodedOutputStream.ComputeFieldSize(fieldDescriptor.FieldType, fieldDescriptor.FieldNumber, value);
       object mungedValue = MungeValue(fieldDescriptor, value);
       int mungedSize = CodedOutputStream.ComputeFieldSize(fieldDescriptor.FieldType, fieldDescriptor.FieldNumber, mungedValue);
       // Exceptions log more easily than assertions
       if (currentSize != mungedSize) {
     throw new Exception("Munged value had wrong size. Field type: " + fieldDescriptor.FieldType
     + "; old value: " + value + "; new value: " + mungedValue);
       }
       return mungedValue;
 }
开发者ID:nuirnr01,项目名称:dotnet-protobufs,代码行数:15,代码来源:Program.cs

示例10: GetAdditionalParameters

        protected virtual FieldDescriptor GetAdditionalParameters(Item standardValues, Dictionary<string, string> additionalParameters)
        {
            Assert.ArgumentNotNull(standardValues, "standardValues");
            Assert.ArgumentNotNull(additionalParameters, "additionalParameters");

            var value = new UrlString();
            foreach (var key in additionalParameters.Keys)
            {
                value[key] = HttpUtility.UrlDecode(additionalParameters[key]);
            }

            var descriptor = new FieldDescriptor(standardValues, "Additional Parameters") { Value = value.ToString() };
            return descriptor;
        }
开发者ID:JRondeau16,项目名称:sitecore-clientextensions,代码行数:14,代码来源:GetFields.cs

示例11: Serialize

        /// <summary>
        /// 
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="rootObjectFieldDescriptor"></param>
        /// <param name="textWriter"></param>
        /// <param name="translationContext"></param>
        private void Serialize(object obj, FieldDescriptor rootObjectFieldDescriptor, TextWriter textWriter,
            TranslationContext translationContext)
        {
            SerializationPreHook(obj, translationContext);

            WriteObjectStart(rootObjectFieldDescriptor, textWriter);

            IEnumerable<FieldDescriptor> allFieldDescriptors = GetClassDescriptor(obj).AllFieldDescriptors;

            SerializeFields(obj, textWriter, translationContext, allFieldDescriptors.ToList());

            WriteClose(textWriter);

            SerializationPostHook(obj, translationContext);
        }
开发者ID:ecologylab,项目名称:simplCSharp,代码行数:22,代码来源:BibtexSerializer.cs

示例12: AddToMapOrMarkUnresolved

        private void AddToMapOrMarkUnresolved(object root, FieldDescriptor currentFieldDescriptor, object subRoot,
            string simplId)
        {
            IDictionary collection =
                (IDictionary) currentFieldDescriptor.AutomaticLazyGetCollectionOrMap(root);

            if (subRoot != null)
            {
                var mappable = subRoot as IMappable<object>;
                if (mappable != null)
                {
                    var key = mappable.Key();
                    collection.Add(key, mappable);
                }
            }
            else
                translationContext.RefObjectNeedsIdResolve(collection, null, simplId);
        }
开发者ID:ecologylab,项目名称:simplCSharp,代码行数:18,代码来源:JsonPullDeserializer.cs

示例13: SingleFieldAccessor

        internal SingleFieldAccessor(PropertyInfo property, FieldDescriptor descriptor) : base(property, descriptor)
        {
            if (!property.CanWrite)
            {
                throw new ArgumentException("Not all required properties/methods available");
            }
            setValueDelegate = ReflectionUtil.CreateActionIMessageObject(property.GetSetMethod());

            var clrType = property.PropertyType;
            
            // TODO: Validate that this is a reasonable single field? (Should be a value type, a message type, or string/ByteString.)
            object defaultValue =
                descriptor.FieldType == FieldType.Message ? null
                : clrType == typeof(string) ? ""
                : clrType == typeof(ByteString) ? ByteString.Empty
                : Activator.CreateInstance(clrType);
            clearDelegate = message => SetValue(message, defaultValue);
        }
开发者ID:2php,项目名称:protobuf,代码行数:18,代码来源:SingleFieldAccessor.cs

示例14: SerializeScalar

        private static void SerializeScalar(object obj, FieldDescriptor fd, TextWriter textWriter, TranslationContext translationContext)
        {
            // check wether we need quotation marks to surround the value.
            bool needQuotationMarks = true;
            ScalarType st = fd.ScalarType;
            if (st != null)
            {
                needQuotationMarks = st.NeedsJsonQuotationWrap();
            }

            textWriter.Write('"');
            textWriter.Write(fd.TagName);
            textWriter.Write('"');
            textWriter.Write(':');
            if (needQuotationMarks)
                textWriter.Write('"');
            fd.AppendValue(textWriter, obj, translationContext, Format.Json);
            if (needQuotationMarks)
                textWriter.Write('"');
        }
开发者ID:ecologylab,项目名称:simplCSharp,代码行数:20,代码来源:JsonSerializer.cs

示例15: Serialize

        /// <summary>
        /// 
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="rootObjectFieldDescriptor"></param>
        /// <param name="binaryWriter"></param>
        /// <param name="translationContext"></param>
        private void Serialize(object obj, FieldDescriptor rootObjectFieldDescriptor, BinaryWriter binaryWriter,
            TranslationContext translationContext)
        {
            if (AlreadySerialized(obj, translationContext))
            {
                WriteSimplRef(obj, rootObjectFieldDescriptor, binaryWriter);
                return;
            }

            translationContext.MapObject(obj);

            SerializationPreHook(obj, translationContext);
            ClassDescriptor rootObjectClassDescriptor = GetClassDescriptor(obj);

            MemoryStream bufferMemoryStream = new MemoryStream();
            BinaryWriter outputBuffer = new BinaryWriter(bufferMemoryStream);

            IEnumerable<FieldDescriptor> allFieldDescriptors = GetClassDescriptor(obj).AllFieldDescriptors;

            SerializeFields(obj, outputBuffer, translationContext, allFieldDescriptors.ToList());
            WriteHeader(binaryWriter, bufferMemoryStream, rootObjectFieldDescriptor.TlvId);
            SerializationPostHook(obj, translationContext);
        }
开发者ID:ecologylab,项目名称:simplCSharp,代码行数:30,代码来源:TlvSerializer.cs


注:本文中的FieldDescriptor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。