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


C# IMemberContext类代码示例

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


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

示例1: GetActualType

 public Type GetActualType(XObject source, IMemberContext target, IAdviceRequester adviceRequester)
 {
     return Converters
             .Select(c => c.GetActualType(source, target, adviceRequester))
             .Where(t => t != null)
             .FirstOrDefault();
 }
开发者ID:kimbirkelund,项目名称:SekhmetSerialization,代码行数:7,代码来源:CompositeTypeConverter.cs

示例2: CreateForDeserialization

 public IObjectContext CreateForDeserialization(IMemberContext targetMember, Type targetType, IAdviceRequester adviceRequester)
 {
     return Factories
         .Select(f => f.CreateForDeserialization(targetMember, targetType, adviceRequester))
         .Where(d => d != null)
         .FirstOrDefault();
 }
开发者ID:kimbirkelund,项目名称:SekhmetSerialization,代码行数:7,代码来源:CompositeObjectContextFactory.cs

示例3: Select

 public IDeserializer Select(XObject source, IMemberContext target, IAdviceRequester adviceRequester)
 {
     return Selectors
             .Select(s => s.Select(source, target, adviceRequester))
             .Where(d => d != null)
             .FirstOrDefault();
 }
开发者ID:kimbirkelund,项目名称:SekhmetSerialization,代码行数:7,代码来源:CompositeDeserializerSelector.cs

示例4: CreateForSerialization

 public IObjectContext CreateForSerialization(IMemberContext sourceMember, object source, IAdviceRequester adviceRequester)
 {
     return Factories
         .Select(f => f.CreateForSerialization(sourceMember, source, adviceRequester))
         .Where(d => d != null)
         .FirstOrDefault();
 }
开发者ID:kimbirkelund,项目名称:SekhmetSerialization,代码行数:7,代码来源:CompositeObjectContextFactory.cs

示例5: Serialize

        public bool Serialize(IMemberContext source, XObject target, IAdviceRequester adviceRequester)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (target.NodeType != XmlNodeType.Element)
                throw new ArgumentException("Parameter must be an XML element.", "target");

            var elem = (XElement)target;

            IObjectContext sourceObject = source.GetValue();

            if (sourceObject == null || sourceObject.GetObject() == null)
            {
                if (_isNullableStrategy.IsNullable(source, elem, adviceRequester))
                {
                    elem.Add(Constants.XsiNilAttribute);
                    return true;
                }

                return false;
            }

            List<IMapping<IMemberContext, XObject>> mappings = _mapper.MapForSerialization(source, elem, adviceRequester)
                .ToList();
            if (mappings == null)
                throw new ArgumentException("Unable to map source '" + source + "' and target '" + target + "'.");

            SerializeRecursively(elem, mappings, adviceRequester);

            return true;
        }
开发者ID:kimbirkelund,项目名称:SekhmetSerialization,代码行数:31,代码来源:RecursiveSerializer.cs

示例6: EmitContext

		// TODO: Replace IMemberContext with MemberCore
		public EmitContext (IMemberContext rc, ILGenerator ig, TypeSpec return_type)
		{
			this.MemberContext = rc;
			this.ig = ig;

			this.return_type = return_type;
		}
开发者ID:Tak,项目名称:monodevelop-novell,代码行数:8,代码来源:codegen.cs

示例7: Select

        public ISerializer Select(IMemberContext source, XObject target, IAdviceRequester adviceRequester)
        {
            if (target.NodeType != XmlNodeType.Element)
                return null;

            return _serializer;
        }
开发者ID:kimbirkelund,项目名称:SekhmetSerialization,代码行数:7,代码来源:RecursiveSerializerSelector.cs

示例8: Deserialize

        public void Deserialize(XObject source, IMemberContext target, IAdviceRequester adviceRequester)
        {
            if (source == null)
                return;

            if (source.NodeType != XmlNodeType.Element)
                throw new ArgumentException("Parameter must be an XML element.", "source");

            if (_log.IsDebugEnabled)
                _log.Debug("Deserializing " + source.ToFriendlyName() + " into " + target + ".");

            var elem = (XElement)source;

            Type targetType = _typeConverter.GetActualType(source, target, adviceRequester);
            if (targetType == null)
                throw new ArgumentException("Unable to get target type for target '" + target + "'.");

            IObjectContext targetObject = _objectContextFactory.CreateForDeserialization(target, targetType, adviceRequester);
            if (targetObject == null)
                throw new ArgumentException("Unable to create target object for target '" + target + "'.");

            target.SetValue(targetObject);

            List<IMapping<XObject, IMemberContext>> mappings = _mapper.MapForDeserialization(elem, target, adviceRequester)
                .ToList();
            if (mappings == null)
                throw new ArgumentException("Unable to map source '" + source + "' and target '" + target + "'.");

            DeserializeRecursively(mappings, adviceRequester);

            target.CommitChanges();
        }
开发者ID:kimbirkelund,项目名称:SekhmetSerialization,代码行数:32,代码来源:RecursiveDeserializer.cs

示例9: CreateMappingForSerialization

        private static IMapping<IMemberContext, XObject> CreateMappingForSerialization(IMemberContext member, XElement target)
        {
            var targetTypeAndName = GetTargetTypeAndName(member);

            XObject xobj;
            bool addTargetToParent = true;
            switch (targetTypeAndName.Key)
            {
                case XmlNodeType.Element:
                    if (!member.ContractType.IsSubTypeOf<IXmlSerializable>() && member.ContractType.IsCollectionType() && HasXmlElementAttribute(member) || HasXmlTextAttribute(member))
                    {
                        xobj = target;
                        addTargetToParent = false;
                    }
                    else
                        xobj = new XElement(targetTypeAndName.Value);
                    break;
                case XmlNodeType.Attribute:
                    xobj = new XAttribute(targetTypeAndName.Value, string.Empty);
                    break;
                default:
                    throw new ArgumentOutOfRangeException("Mapped to an unknown node type: " + targetTypeAndName.Key + ".");
            }

            return new Mapping<IMemberContext, XObject>(member, xobj, addTargetToParent);
        }
开发者ID:kimbirkelund,项目名称:SekhmetSerialization,代码行数:26,代码来源:XmlSerializerMapper.cs

示例10: MapForDeserialization

        public IEnumerable<IMapping<XObject, IMemberContext>> MapForDeserialization(XElement source, IMemberContext target, IAdviceRequester adviceRequester)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (target == null)
                throw new ArgumentNullException("target");

            var targetObject = target.GetValue();
            foreach (var member in targetObject.Members.Where(m => !m.Attributes.OfType<XmlIgnoreAttribute>().Any()))
            {
                var sourceType = GetSourceTypeAndPotentialNames(member);

                switch (sourceType.Key)
                {
                    case XmlNodeType.Element:
                        foreach (var mapping in GetMappingsFromElement(sourceType.Value, source, targetObject, member, adviceRequester))
                            yield return mapping;
                        break;
                    case XmlNodeType.Attribute:
                        yield return GetMappingFromAttribute(sourceType.Value, source, member);
                        break;
                    default:
                        throw new ArgumentOutOfRangeException();
                }
            }
        }
开发者ID:kimbirkelund,项目名称:SekhmetSerialization,代码行数:26,代码来源:XmlSerializerMapper.cs

示例11: Select

        protected virtual IDeserializer Select(XObject source, IMemberContext target, Type type, IAdviceRequester adviceRequester)
        {
            var typeCode = Type.GetTypeCode(type);

            switch (typeCode)
            {
                case TypeCode.Empty:
                case TypeCode.DBNull:
                    return null;
                case TypeCode.Object:
                    if (target.ContractType == typeof(TimeSpan))
                        break;
                    if (target.ContractType == typeof(string))
                        break;
                    if (target.ContractType.IsNullable())
                        break;

                    return null;
            }

            if (source == null)
                return GetDeserializer(type);

            if (source.NodeType == XmlNodeType.Element && !((XElement)source).HasElements)
                return GetDeserializer(type);

            if (source.NodeType == XmlNodeType.Attribute)
                return GetDeserializer(type);

            return null;
        }
开发者ID:kimbirkelund,项目名称:SekhmetSerialization,代码行数:31,代码来源:ValueTypeDeserializerSelector.cs

示例12: GetActualTypeFromXmlElementAttribute

        private static Type GetActualTypeFromXmlElementAttribute(XElement source, IMemberContext target)
        {
            if (source == null)
                return null;

            return GetTypeFromXmlElementAttributeWithMatchingName(source, target)
                   ?? GetTypeFromXmlElementAttributeWithoutName(target);
        }
开发者ID:kimbirkelund,项目名称:SekhmetSerialization,代码行数:8,代码来源:XmlSerializerTypeConverter.cs

示例13: Select

        public override IDeserializer Select(XObject source, IMemberContext target, IAdviceRequester adviceRequester)
        {
            var contractTypeFromAttr = GetContractTypeFromAttributes(source, target);
            if (contractTypeFromAttr == null)
                return null;

            return Select(source, target, contractTypeFromAttr, adviceRequester);
        }
开发者ID:kimbirkelund,项目名称:SekhmetSerialization,代码行数:8,代码来源:XmlSerializerValueTypeDeserializerSelector.cs

示例14: MultipleMatchesAdviceRequestedEventArgs

 public MultipleMatchesAdviceRequestedEventArgs(XElement source, IObjectContext targetOwner, IMemberContext target, IEnumerable<XObject> matches, XObject selectedMatch)
     : base(CommonAdviceTypes.MultipleMatches)
 {
     Source = source;
     TargetOwner = targetOwner;
     Target = target;
     Matches = (matches ?? Enumerable.Empty<XObject>()).ToList();
     SelectedMatch = selectedMatch;
 }
开发者ID:kimbirkelund,项目名称:SekhmetSerialization,代码行数:9,代码来源:MultipleMatchesAdviceRequestedEventArgs.cs

示例15: ResolveType

		public bool ResolveType(IMemberContext mc, TypeSpec defaultType)
		{
			if (TypeExpression != null)
				this.Type = TypeExpression.ResolveAsType (mc);
			else
				this.Type = defaultType;

			return this.Type != null;
		}
开发者ID:rlfqudxo,项目名称:playscript-mono,代码行数:9,代码来源:field.cs


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