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

C# IMemberContext类代码示例

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

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



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


示例16: CreateForSerialization

        public IObjectContext CreateForSerialization(IMemberContext sourceMember, object source, IAdviceRequester adviceRequester)
        {
            if (source == null)
                return null;

            ObjectContextInfo contextInfo = GetContextInfo(source.GetType(), adviceRequester);

            return contextInfo.CreateFor(source);
        }
开发者ID:kimbirkelund,项目名称:SekhmetSerialization,代码行数:9,代码来源:CachingObjectContextFactory.cs


示例17: CreateForDeserialization

        public IObjectContext CreateForDeserialization(IMemberContext targetMember, Type targetType, IAdviceRequester adviceRequester)
        {
            ObjectContextInfo contextInfo = GetContextInfo(targetType, adviceRequester);

            object target = _instantiator.Create(targetType, adviceRequester);
            if (target == null)
                throw new ArgumentException("Unable to create instance of '" + targetType + "' for member '" + targetMember + "'.");

            return contextInfo.CreateFor(target);
        }
开发者ID:kimbirkelund,项目名称:SekhmetSerialization,代码行数:10,代码来源:CachingObjectContextFactory.cs


示例18: GetTypeFromXmlAttributeAttributeWithoutName

 private static Type GetTypeFromXmlAttributeAttributeWithoutName(IMemberContext target)
 {
     return target.Attributes
             .OfType<XmlAttributeAttribute>()
             .Where(a => string.IsNullOrWhiteSpace(a.AttributeName))
             .Where(a => a.Type != null)
             .Where(a => target.ContractType.IsAssignableFrom(a.Type))
             .Select(a => a.Type)
             .FirstOrDefault();
 }
开发者ID:kimbirkelund,项目名称:SekhmetSerialization,代码行数:10,代码来源:XmlSerializerTypeConverter.cs


示例19: DoResolveAsTypeStep

		protected override TypeExpr DoResolveAsTypeStep (IMemberContext ec)
		{
			var type = ec.Module.PredefinedTypes.Nullable.Resolve (loc);
			if (type == null)
				return null;

			TypeArguments args = new TypeArguments (underlying);
			GenericTypeExpr ctype = new GenericTypeExpr (type, args, loc);
			return ctype.ResolveAsTypeTerminal (ec, false);
		}
开发者ID:saga,项目名称:mono,代码行数:10,代码来源:nullable.cs


示例20: ResolveAsType

		public override TypeExpr ResolveAsType (IMemberContext ec)
		{
			var type = ec.Module.PredefinedTypes.Nullable.Resolve ();
			if (type == null)
				return null;

			TypeArguments args = new TypeArguments (underlying);
			GenericTypeExpr ctype = new GenericTypeExpr (type, args, loc);
			return ctype.ResolveAsType (ec);
		}
开发者ID:constructor-igor,项目名称:cudafy,代码行数:10,代码来源:nullable.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# IMemberDefinition类代码示例发布时间:2022-05-24
下一篇:
C# IMember类代码示例发布时间: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