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


C# IObjectDescriptor类代码示例

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


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

示例1: Enter

        public override bool Enter(IObjectDescriptor value, IEmitter context)
        {
            var typeConverter = typeConverters.FirstOrDefault(t => t.Accepts(value.Type));
            if (typeConverter != null)
            {
                typeConverter.WriteYaml(context, value.Value, value.Type);
                return false;
            }

            var convertible = value.Value as IYamlConvertible;
            if (convertible != null)
            {
                convertible.Write(context, nestedObjectSerializer);
                return false;
            }

            #pragma warning disable 0618 // IYamlSerializable is obsolete
            var serializable = value.Value as IYamlSerializable;
            if (serializable != null)
            {
                serializable.WriteYaml(context);
                return false;
            }
            #pragma warning restore

            return base.Enter(value, context);
        }
开发者ID:aaubry,项目名称:YamlDotNet,代码行数:27,代码来源:CustomSerializationObjectGraphVisitor.cs

示例2: TraverseProperties

        protected override void TraverseProperties(IObjectDescriptor value, IObjectGraphVisitor visitor, int currentDepth)
        {
            if (!ReflectionUtility.HasDefaultConstructor(value.Type) && !serializer.Converters.Any(c => c.Accepts(value.Type)))
            {
                throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Type '{0}' cannot be deserialized because it does not have a default constructor or a type converter.", value.Type));
            }

            base.TraverseProperties(value, visitor, currentDepth);
        }
开发者ID:kitsilanosoftware,项目名称:YamlDotNet,代码行数:9,代码来源:RoundtripObjectGraphTraversalStrategy.cs

示例3: EnterMapping

		public override bool EnterMapping(IPropertyDescriptor key, IObjectDescriptor value)
		{
			var defaultValueAttribute = key.GetCustomAttribute<DefaultValueAttribute>();
			var defaultValue = defaultValueAttribute != null
				? defaultValueAttribute.Value
				: GetDefault(key.Type);

			return !_objectComparer.Equals(value.Value, defaultValue)
				   && base.EnterMapping(key, value);
		}
开发者ID:danieldeb,项目名称:EventStore,代码行数:10,代码来源:DefaultExclusiveObjectGraphVisitor.cs

示例4: Enter

		public override bool Enter(IObjectDescriptor value)
		{
			var alias = aliasProvider.GetAlias(value.Value);
			if (alias != null && !emittedAliases.Add(alias))
			{
				eventEmitter.Emit(new AliasEventInfo(value) { Alias = alias });
				return false;
			}

			return base.Enter(value);
		}
开发者ID:ActivePHOENiX,项目名称:YamlDotNet,代码行数:11,代码来源:AnchorAssigningObjectGraphVisitor.cs

示例5: EmitDocument

        private void EmitDocument(IEmitter emitter, IObjectDescriptor graph)
        {
            var traversalStrategy = CreateTraversalStrategy();
            var eventEmitter = CreateEventEmitter(emitter);
            var emittingVisitor = CreateEmittingVisitor(emitter, traversalStrategy, eventEmitter, graph);

            emitter.Emit(new StreamStart());
            emitter.Emit(new DocumentStart());

            traversalStrategy.Traverse(graph, emittingVisitor);

            emitter.Emit(new DocumentEnd(true));
            emitter.Emit(new StreamEnd());
        }
开发者ID:vwxyzh,项目名称:Zhenway.YamlSerializations,代码行数:14,代码来源:YamlSerializer.cs

示例6: Enter

        protected override bool Enter(IObjectDescriptor value)
        {
            AnchorAssignment assignment;
            if (value.Value != null && assignments.TryGetValue(value.Value, out assignment))
            {
                if (assignment.Anchor == null)
                {
                    assignment.Anchor = "o" + nextId.ToString(CultureInfo.InvariantCulture);
                    ++nextId;
                }
                return false;
            }

            return true;
        }
开发者ID:aaubry,项目名称:YamlDotNet,代码行数:15,代码来源:AnchorAssigner.cs

示例7: Enter

		public override bool Enter(IObjectDescriptor value)
		{
			var typeConverter = typeConverters.FirstOrDefault(t => t.Accepts(value.Type));
			if (typeConverter != null)
			{
				typeConverter.WriteYaml(emitter, value.Value, value.Type);
				return false;
			}

			var serializable = value as IYamlSerializable;
			if (serializable != null)
			{
				serializable.WriteYaml(emitter);
				return false;
			}

			return base.Enter(value);
		}
开发者ID:Cyberbanan,项目名称:Projeny,代码行数:18,代码来源:CustomSerializationObjectGraphVisitor.cs

示例8: CreateEmittingVisitor

        private IObjectGraphVisitor CreateEmittingVisitor(IEmitter emitter, IObjectGraphTraversalStrategy traversalStrategy, IEventEmitter eventEmitter, IObjectDescriptor graph)
        {
            IObjectGraphVisitor emittingVisitor = new EmittingObjectGraphVisitor(eventEmitter);

            emittingVisitor = new CustomSerializationObjectGraphVisitor(emitter, emittingVisitor, Converters);

            if (!IsOptionSet(SerializationOptions.DisableAliases))
            {
                var anchorAssigner = new AnchorAssigner();
                traversalStrategy.Traverse(graph, anchorAssigner);

                emittingVisitor = new AnchorAssigningObjectGraphVisitor(emittingVisitor, eventEmitter, anchorAssigner);
            }

            if (!IsOptionSet(SerializationOptions.EmitDefaults))
            {
                emittingVisitor = new DefaultExclusiveObjectGraphVisitor(emittingVisitor);
            }

            return emittingVisitor;
        }
开发者ID:vwxyzh,项目名称:Zhenway.YamlSerializations,代码行数:21,代码来源:YamlSerializer.cs

示例9: AnchorAssignment

        bool IObjectGraphVisitor.Enter(IObjectDescriptor value)
        {
            // Do not assign anchors to basic types
            if (value.Value == null || value.Type.GetTypeCode() != TypeCode.Object)
            {
                return false;
            }

            AnchorAssignment assignment;
            if (assignments.TryGetValue(value.Value, out assignment))
            {
                if (assignment.Anchor == null)
                {
                    assignment.Anchor = "o" + nextId.ToString(CultureInfo.InvariantCulture);
                    ++nextId;
                }
                return false;
            }
            else
            {
                assignments.Add(value.Value, new AnchorAssignment());
                return true;
            }
        }
开发者ID:KevinAllenWiegand,项目名称:SaintCoinach,代码行数:24,代码来源:AnchorAssigner.cs

示例10:

		bool IObjectGraphVisitor.EnterMapping(IPropertyDescriptor key, IObjectDescriptor value)
		{
			return true;
		}
开发者ID:adbrowne,项目名称:EventStore,代码行数:4,代码来源:EmittingObjectGraphVisitor.cs

示例11: VisitMappingStart

 public virtual void VisitMappingStart(IObjectDescriptor mapping, Type keyType, Type valueType)
 {
     nextVisitor.VisitMappingStart(mapping, keyType, valueType);
 }
开发者ID:kitsilanosoftware,项目名称:YamlDotNet,代码行数:4,代码来源:ChainedObjectGraphVisitor.cs

示例12: VisitSequenceEnd

 public virtual void VisitSequenceEnd(IObjectDescriptor sequence)
 {
     nextVisitor.VisitSequenceEnd(sequence);
 }
开发者ID:kitsilanosoftware,项目名称:YamlDotNet,代码行数:4,代码来源:ChainedObjectGraphVisitor.cs

示例13: VisitScalar

		public override void VisitScalar(IObjectDescriptor scalar)
		{
			eventEmitter.Emit(new ScalarEventInfo(scalar) { Anchor = aliasProvider.GetAlias(scalar.Value) });
		}
开发者ID:ActivePHOENiX,项目名称:YamlDotNet,代码行数:4,代码来源:AnchorAssigningObjectGraphVisitor.cs

示例14: EnterMapping

 public virtual bool EnterMapping(IPropertyDescriptor key, IObjectDescriptor value)
 {
     return nextVisitor.EnterMapping(key, value);
 }
开发者ID:kitsilanosoftware,项目名称:YamlDotNet,代码行数:4,代码来源:ChainedObjectGraphVisitor.cs

示例15: VisitMappingStart

		public override void VisitMappingStart(IObjectDescriptor mapping, Type keyType, Type valueType)
		{
			eventEmitter.Emit(new MappingStartEventInfo(mapping) { Anchor = aliasProvider.GetAlias(mapping.Value) });
		}
开发者ID:ActivePHOENiX,项目名称:YamlDotNet,代码行数:4,代码来源:AnchorAssigningObjectGraphVisitor.cs


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