• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# FieldDescriptor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: PrintField

 internal static void PrintField(FieldDescriptor field, object value, TextGenerator generator)
 {
     if (field.IsRepeated)
     {
         // Repeated field.  Print each element.
         foreach (object element in (IEnumerable) value)
         {
             PrintSingleField(field, element, generator);
         }
     }
     else
     {
         PrintSingleField(field, value, generator);
     }
 }
开发者ID:JuWell,项目名称:SmallNetGame,代码行数:15,代码来源:TextFormat.cs


示例17: PrintSingleField

        private static void PrintSingleField(FieldDescriptor field, Object value, TextGenerator generator)
        {
            if (field.IsExtension)
            {
                generator.Print("[");
                // We special-case MessageSet elements for compatibility with proto1.
                if (field.ContainingType.Options.MessageSetWireFormat
                    && field.FieldType == FieldType.Message
                    && field.IsOptional
                    // object equality (TODO(jonskeet): Work out what this comment means!)
                    && field.ExtensionScope == field.MessageType)
                {
                    generator.Print(field.MessageType.FullName);
                }
                else
                {
                    generator.Print(field.FullName);
                }
                generator.Print("]");
            }
            else
            {
                if (field.FieldType == FieldType.Group)
                {
                    // Groups must be serialized with their original capitalization.
                    generator.Print(field.MessageType.Name);
                }
                else
                {
                    generator.Print(field.Name);
                }
            }

            if (field.MappedType == MappedType.Message)
            {
                generator.Print(" {\n");
                generator.Indent();
            }
            else
            {
                generator.Print(": ");
            }

            PrintFieldValue(field, value, generator);

            if (field.MappedType == MappedType.Message)
            {
                generator.Outdent();
                generator.Print("}");
            }
            generator.Print("\n");
        }
开发者ID:JuWell,项目名称:SmallNetGame,代码行数:52,代码来源:TextFormat.cs


示例18: GetDescriptor

 /// <summary>
 /// Returns a SysDOM field descriptor for a particular instance
 /// </summary>
 /// <param name="inst">instance of class containing the field</param>
 /// <returns>SysDOM field descriptor</returns>
 public FieldDescriptor GetDescriptor(object inst)
 {
     if (inst == null)
     {
         if (_nullInstDesc == null)
         {
             _nullInstDesc = new CILFieldDescriptor(Field, null)
             {
                 IsConstant = !IsWritten && !IsSubMutated
             };
         }
         return _nullInstDesc;
     }
     else
     {
         FieldDescriptor result;
         if (!_descMap.TryGetValue(inst, out result))
         {
             result = new CILFieldDescriptor(Field, inst)
             {
                 IsConstant = !IsWritten && !IsSubMutated
             };
             _descMap[inst] = result;
         }
         return result;
     }
 }
开发者ID:venusdharan,项目名称:systemsharp,代码行数:32,代码来源:FieldFacts.cs


示例19: SubMessagePrefix

 private static String SubMessagePrefix(String prefix, FieldDescriptor field, int index)
 {
     StringBuilder result = new StringBuilder(prefix);
     if (field.IsExtension)
     {
         result.Append('(')
             .Append(field.FullName)
             .Append(')');
     }
     else
     {
         result.Append(field.Name);
     }
     if (index != -1)
     {
         result.Append('[')
             .Append(index)
             .Append(']');
     }
     result.Append('.');
     return result.ToString();
 }
开发者ID:ZhouX1ang,项目名称:protobuf-csharp-port,代码行数:22,代码来源:UninitializedMessageException.cs


示例20: CreateColumnFromItemsSourceField

    public static Column CreateColumnFromItemsSourceField(
      DataGridControl dataGridControl,
      IDictionary<Type, CellEditor> defaultCellEditors,
      FieldDescriptor field,
      bool autoCreateForeignKeyConfigurations )
    {
      if( ( field.IsASubRelationship ) || ( !field.Browsable ) )
        return null;

      string fieldName = field.Name;
      Type dataType = field.DataType;

      Column dataColumn = new Column();
      dataColumn.IsAutoCreated = true;
      dataColumn.FieldName = fieldName;

      bool readOnly = field.ReadOnly;
      bool overrideReadOnlyForInsertion = field.OverrideReadOnlyForInsertion;

      // We only set ReadOnly when the value is true in order for the inheritence chain to work.  
      // Otherwise, the column value is always used instead of the row or grid value.
      if( readOnly )
        dataColumn.ReadOnly = readOnly;

      dataColumn.OverrideReadOnlyForInsertion = overrideReadOnlyForInsertion;
      dataColumn.Title = field.DisplayName;

      // Disable warning for DisplayMemberBinding when internaly used
#pragma warning disable 618

      dataColumn.DisplayMemberBinding = ItemsSourceHelper.CreateDefaultBinding(
        false, field.Name, field,
        false, ( readOnly && !overrideReadOnlyForInsertion ), dataType );

#pragma warning restore 618

      //mark the Column's Binding as AutoCreated.
      dataColumn.IsBindingAutoCreated = true;
      dataColumn.IsBoundToDataGridUnboundItemProperty = field.IsDataGridUnboundItemProperty;

      CellEditor cellEditor = null;

      if( defaultCellEditors != null )
      {
        defaultCellEditors.TryGetValue( dataType, out cellEditor );
      }

      if( ( field.ForeignKeyDescription != null )
        && ( field.ForeignKeyDescription.ItemsSource != null )
        && ( autoCreateForeignKeyConfigurations ) )
      {
        // We will only use the default foreign key CellEditor
        // if:
        // - a ForeignKey ItemsSource was detected
        // - the grid allows the auto-creation of the ForeignKeyConfigurations
        // else, use the default CellEditor
        if( cellEditor == null )
        {
          cellEditor = DefaultCellEditorSelector.ForeignKeyCellEditor;
        }

        // Update the ForeignKeyConfiguration from the ForeignKeyDescription
        // found on the FieldDescriptor
        ForeignKeyConfiguration.SynchronizeForeignKeyConfigurationFromForeignKeyDescription(
          dataColumn,
          field.ForeignKeyDescription,
          autoCreateForeignKeyConfigurations );
      }

      if( cellEditor == null )
      {
        cellEditor = DefaultCellEditorSelector.SelectCellEditor( dataType );
      }

      dataColumn.CellEditor = cellEditor;
      return dataColumn;
    }
开发者ID:Torion,项目名称:WpfExToolkit,代码行数:77,代码来源:ItemsSourceHelper.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# FieldInfo类代码示例发布时间:2022-05-24
下一篇:
C# FieldDefinition类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap