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


C# SerializationContext.GetTypeHandler方法代码示例

本文整理汇总了C#中SerializationContext.GetTypeHandler方法的典型用法代码示例。如果您正苦于以下问题:C# SerializationContext.GetTypeHandler方法的具体用法?C# SerializationContext.GetTypeHandler怎么用?C# SerializationContext.GetTypeHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SerializationContext的用法示例。


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

示例1: ConvertTo

        public override object ConvertTo(object item, Type sourceType, SerializationContext serializationContext)
        {
            IDictionary dictionary = (IDictionary) Activator.CreateInstance(sourceType);
            ICollection coll = (ICollection)item;
            foreach (object colItem in coll)
            {
                IPropertyData propHandler = serializationContext.GetTypeHandler(colItem.GetType()).FindProperty(Context.ToString());
                if (propHandler == null)
                {
                    throw new MissingMemberException("Type: " + item.GetType().Name + " does not have an accessible property: " + Context);
                }

                dictionary[propHandler.GetValue(colItem)] = colItem;
            }
            return dictionary;
        }
开发者ID:BryanApellanes,项目名称:Naizari,代码行数:16,代码来源:DictionaryToListConverter.cs

示例2: ConverterUtil

 public ConverterUtil(Type forType, SerializationContext context)
 {
     _handler = context.GetTypeHandler(forType);
 }
开发者ID:Letractively,项目名称:gabesworkshop,代码行数:4,代码来源:ConverterUtil.cs

示例3: ResolveConstructorTypes

        /// <summary>
        /// Resolves and updates the types of any constructor arguments
        /// </summary>
        /// <param name="context">serialization context</param>
        /// <param name="expression">object expression</param>
        protected static void ResolveConstructorTypes(SerializationContext context, ObjectExpression expression)
        {
            TypeData handler = context.GetTypeHandler(expression.ResultType);
            Type[] definedTypes = GetConstructorParameterTypes(handler.ConstructorParameters);

            CtorArgTypeResolver resolver = new CtorArgTypeResolver(expression, context, definedTypes);
            Type[] resolvedTypes = resolver.ResolveTypes();
            for (int i = 0; i < resolvedTypes.Length; i++)
            {
                if (resolvedTypes[i] != null)
                    expression.ConstructorArguments[i].ResultType = resolvedTypes[i];
            }
        }
开发者ID:BryanApellanes,项目名称:Naizari,代码行数:18,代码来源:ObjectExpressionHandler.cs


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