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

C# TypeDescriptor类代码示例

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

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



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

示例1: LoadTypeFromDescriptor

 public Type LoadTypeFromDescriptor(TypeDescriptor typeDescriptor)
 {
     if (typeDescriptor.TypeDescriptors.Count == 0)
         return LoadTypeFromName(typeDescriptor.Name);
     var typeParams = typeDescriptor
         .TypeDescriptors
         .Select(LoadTypeFromDescriptor)
         .ToArray();
     return LoadTypeFromName(typeDescriptor.Name, typeParams);
 }
开发者ID:buunguyen,项目名称:bike,代码行数:10,代码来源:ClrImportContext.cs


示例2: FindMethodImplementation

 public MethodDescriptor FindMethodImplementation(MethodDescriptor methodDescriptor, TypeDescriptor typeDescriptor)
 {
     var roslynMethod = FindMethod(methodDescriptor);
     if (roslynMethod != null)
     {
         var roslynType = RoslynSymbolFactory.GetTypeByName(typeDescriptor.TypeName, this.Compilation);
         var implementedMethod = Utils.FindMethodImplementation(roslynMethod, roslynType);
         return new MethodDescriptor(implementedMethod);
     }
     // If we cannot resolve the method, we return the same method.
     return methodDescriptor;
 }
开发者ID:TubaKayaDev,项目名称:Call-Graph-Builder-DotNet,代码行数:12,代码来源:CodeProvider.cs


示例3: TryAllocate

 public IXILMapping TryAllocate(Component host, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes, IProject proj)
 {
     List<IXILMapper> mappers = _mlookup.Get(instr.Name);
     foreach (IXILMapper mapper in mappers)
     {
         IXILMapping mapping = mapper.TryAllocate(host, instr, operandTypes, resultTypes, proj);
         if (mapping != null)
         {
             return mapping;
         }
     }
     return null;
 }
开发者ID:venusdharan,项目名称:systemsharp,代码行数:13,代码来源:XILMapping.cs


示例4: GetName

        internal static string GetName(this MemberInfo @this, Assembly containingAssembly, 
			bool isDeclaration)
        {
            var methodName = string.Empty;

            if(!isDeclaration)
            {
                methodName += new TypeDescriptor(
                    @this.DeclaringType, containingAssembly,
                    @this.DeclaringType.IsGenericType).Value + "::";
            }

            return methodName + @this.Name;
        }
开发者ID:JasonBock,项目名称:EmitDebugging,代码行数:14,代码来源:MemberInfoExtensions.cs


示例5: PropertyDescriptor

        /// <summary>
        /// Initialize a new instance of <see cref="PropertyDescriptor"/>.
        /// </summary>
        /// <param name="propertyInfo">The <see cref="PropertyInfo"/> to wrap.</param>
        /// <param name="typeDescriptor">The <see cref="Reflection.TypeDescriptor"/> this <see cref="PropertyDescriptor"/> belongs to.</param>
        /// <param name="getMethodInfo">The get <see cref="MethodInfo"/> for the <see cref="PropertyInfo"/> being wrapped.</param>
        /// <exception cref="NullReferenceException"><paramref name="propertyInfo"/> is null.</exception>
        internal PropertyDescriptor(TypeDescriptor typeDescriptor, PropertyInfo propertyInfo, MethodInfo getMethodInfo)
            : base(getMethodInfo.ReturnType, propertyInfo.Name)
        {
            if (propertyInfo.PropertyType.IsGenericParameter)
            {
                throw new ArgumentException("propertyInfo cannot be a genetic type.", "propertyInfo");
            }
            TypeDescriptor = typeDescriptor;
            IsStatic = getMethodInfo.IsStatic;
            IsVirtual = getMethodInfo.IsVirtual;
#if(WindowsCE || SILVERLIGHT)
            this.getMethodInfo = getMethodInfo;
#else
            invoker = MethodInvokerCreator.GetMethodInvoker(getMethodInfo);
#endif
			AddRulesForPropertyInfo(propertyInfo);
        }
开发者ID:thekindofme,项目名称:.netcf-Validation-Framework,代码行数:24,代码来源:PropertyDescriptor.cs


示例6: StandartTypeManager

        public StandartTypeManager()
        {
            foreach (var item in Enum.GetValues(typeof(DataType)))
            {
                DataType typeEnum = (DataType)item;
                string alias;
                switch (typeEnum)
                {
                    case DataType.Undefined:
                        alias = "Неопределено";
                        break;
                    case DataType.Boolean:
                        alias = "Булево";
                        break;
                    case DataType.String:
                        alias = "Строка";
                        break;
                    case DataType.Date:
                        alias = "Дата";
                        break;
                    case DataType.Number:
                        alias = "Число";
                        break;
                    case DataType.Type:
                        alias = "Тип";
                        break;
                    case DataType.Object:
                        alias = "Object";
                        break;
                    default:
                        continue;
                }

                var td = new TypeDescriptor()
                {
                    Name = alias,
                    ID = (int)typeEnum
                };

                RegisterType(td, typeof(DataType));

            }

            RegisterType("Null", typeof(NullValueImpl));
        }
开发者ID:Shemetov,项目名称:OneScript,代码行数:45,代码来源:TypeManager.cs


示例7: ToTypedKeyValue_WhenJsonWithDataTypes_DictionaryGetsTypedValues

        public void ToTypedKeyValue_WhenJsonWithDataTypes_DictionaryGetsTypedValues()
        {
            const string json = "{\"Name\":\"Daniel\",\"Age\":31,\"Item\":{\"Int1\":42,\"DateTime1\":\"\\/Date(-3600000+0000)\\/\"}}";
            var typeDescriptor = new TypeDescriptor
                                 {
                                     {"Name", typeof (string)},
                                     {"Age", typeof (int)},
                                     {"Item", typeof (Item)},
                                 };

            var kv = _jsonSerializer.ToTypedKeyValueOrNull(typeDescriptor, json);

            var expectedKv = new Dictionary<string, object>
                             {
                                 {"Name", "Daniel"},{"Age", 31}, {"Item", new Item{Int1 = 42, DateTime1 = new DateTime(1970,01,01)}}
                             };
            CustomAssert.KeyValueEquality(expectedKv, kv);
        }
开发者ID:BlackMael,项目名称:SisoDb-Provider,代码行数:18,代码来源:DynamicServiceStackJsonSerializerTests.cs


示例8: SentAll

        public bool SentAll(IEnumerable<IDistributedEventAggregator> eventAggregators, byte[] messageContent,
            TypeDescriptor descriptor)
        {
            Logger = LogManager.GetLogger(NomadConstants.NOMAD_LOGGER_REPOSITORY, typeof (BasicTopicDeliverySubsystem));

            foreach (IDistributedEventAggregator dea in eventAggregators)
            {
                try
                {
                    dea.OnPublish(messageContent, descriptor);
                }
                catch (Exception e)
                {
                    Logger.Warn(string.Format("Could not sent message '{0}' to DEA: {1}", descriptor, dea), e);
                }
            }

            // using the reliable mechanisms of WCF devlivery is always succesfull to all proper processes
            return true;
        }
开发者ID:NomadPL,项目名称:Nomad,代码行数:20,代码来源:BasicTopicDeliverySubsystem.cs


示例9: Canonicalize

 /// <summary>
 /// Internalizes a type descriptor.
 /// </summary>
 /// <param name="td">a type descriptor</param>
 /// <returns>equivalent type descriptor which is contained inside the library</returns>
 public TypeDescriptor Canonicalize(TypeDescriptor td)
 {
     TypeDescriptor tdOut;
     if (_types.TryGetValue(td, out tdOut))
     {
         return tdOut;
     }
     else
     {
         td = td.Clone();
         _types[td] = td;
         if (!td.HasIntrinsicTypeOverride)
         {
             PackageDescriptor pd = GetPackage(td.CILType);
             td.Package = pd;
             pd.AddChild(td, td.Name);
         }
         return td;
     }
 }
开发者ID:venusdharan,项目名称:systemsharp,代码行数:25,代码来源:TypeLibrary.cs


示例10: FieldDescriptor

        /// <summary>
        /// Initialize a new instance of <see cref="FieldDescriptor"/>.
        /// </summary>
        /// <param name="fieldInfo">The <see cref="FieldInfo"/> to wrap.</param>
        /// <param name="typeDescriptor">The <see cref="Reflection.TypeDescriptor"/> this <see cref="FieldDescriptor"/> belongs to.</param>
        /// <exception cref="NullReferenceException"><paramref name="fieldInfo"/> is null.</exception>
        internal FieldDescriptor(TypeDescriptor typeDescriptor, FieldInfo fieldInfo)
            : base(fieldInfo.FieldType, fieldInfo.Name)
        {
            if (fieldInfo.FieldType.IsGenericParameter)
            {
                throw new ArgumentException("fieldInfo cannot be a genetic type.", "fieldInfo");
            }
            //TODO: Use Dynamic method instead
            this.fieldInfo = fieldInfo;
            TypeDescriptor = typeDescriptor;
            IsStatic = fieldInfo.IsStatic;
//            invoker = MethodInvokerCreator.GetFieldGetInvoker(Type.GetTypeFromHandle(typeDescriptor.RuntimeTypeHandle), fieldInfo);
			var attributes = (IRuleAttribute[])fieldInfo.GetCustomAttributes(RuleAttributeType, true);
            for (var index = 0; index < attributes.Length; index++)
            {
				var fieldRuleAttribute = attributes[index];
                //Make sure each attribute is "aware" of the fieldInfo it's validating
                var rule = fieldRuleAttribute.CreateRule(this);
                Rules.Add(rule);
            }
        }
开发者ID:thekindofme,项目名称:.netcf-Validation-Framework,代码行数:27,代码来源:FieldDescriptor.cs


示例11: UnPackData

        internal static void UnPackData(TypeDescriptor typeDescriptor, byte[] byteStream, out object sendObject, out Type type)
        {
            type = Type.GetType(typeDescriptor.QualifiedName);
            if (type != null)
            {
                var nomadVersion = new Version(type.Assembly.GetName().Version);

                if (!nomadVersion.Equals(typeDescriptor.Version))
                {
                    throw new InvalidCastException("The version of the assembly does not match");
                }
            }

            // try deserializing object
            sendObject = Deserialize(byteStream);

            // check if o is assignable
            if (type != null && !type.IsInstanceOfType(sendObject))
            {
                throw new InvalidCastException("The sent object cannot be casted to sent type");
            }
        }
开发者ID:NomadPL,项目名称:Nomad,代码行数:22,代码来源:MessageSerializer.cs


示例12: ToTypedKeyValueOrNull

        public IDictionary<string, object> ToTypedKeyValueOrNull(TypeDescriptor typeDescriptor, string json)
        {
            if (string.IsNullOrWhiteSpace(json))
                return null;

            var kvRepresentation = Serializer.Deserialize<IDictionary<string, dynamic>>(json);
            if (kvRepresentation == null || kvRepresentation.Count < 1)
                return null;

            foreach (var key in kvRepresentation.Keys.ToArray())
            {
                var membername = key;
                var member = typeDescriptor.Get(membername);

                if (member == null)
                    continue;

                kvRepresentation[membername] = JsonSerializer.DeserializeFromString(kvRepresentation[membername], member.Type);
            }

            return kvRepresentation;
        }
开发者ID:BlackMael,项目名称:SisoDb-Provider,代码行数:22,代码来源:DynamicServiceStackJsonSerializer.cs


示例13: GetTypeString

 private string GetTypeString(TypeDescriptor td)
 {
     if (td.CILType.Equals(typeof(StdLogic)))
         return "std_logic";
     else if (td.CILType.Equals(typeof(StdLogicVector)))
         return "std_logic_vector(" + td.Constraints[0].FirstBound + " downto " + td.Constraints[0].SecondBound + ")";
     else
         throw new NotSupportedException("Only StdLogic/StdLogicVector supported for user ports");
 }
开发者ID:venusdharan,项目名称:systemsharp,代码行数:9,代码来源:AXIMaster.cs


示例14: Enter

 public virtual bool Enter(TypeDescriptor node)
 {
     return true;
 }
开发者ID:buunguyen,项目名称:bike,代码行数:4,代码来源:EnterForWalkerGenerator.cs


示例15: RegisterType

        public TypeDescriptor RegisterType(string name, Type implementingClass)
        {
            if (_knownTypesIndexes.ContainsKey(name))
            {
                var td = GetTypeByName(name);
                if (GetImplementingClass(td.ID) != implementingClass)
                    throw new InvalidOperationException("Name already registered");

                return td;
            }
            else
            {
                var nextId = _knownTypes.Count;
                var typeDesc = new TypeDescriptor()
                {
                    ID = nextId,
                    Name = name
                };

                RegisterType(typeDesc, implementingClass);
                return typeDesc;
            }
        }
开发者ID:pauliv2,项目名称:OneScript,代码行数:23,代码来源:TypeManager.cs


示例16: RegisterAliasFor

 public static void RegisterAliasFor(TypeDescriptor td, string alias)
 {
     _instance.RegisterAliasFor(td, alias);
 }
开发者ID:pauliv2,项目名称:OneScript,代码行数:4,代码来源:TypeManager.cs


示例17: SortDirectionEnum

 public SortDirectionEnum(TypeDescriptor typeRepresentation, TypeDescriptor valuesType)
     : base(typeRepresentation, valuesType)
 {
 }
开发者ID:pauliv2,项目名称:OneScript,代码行数:4,代码来源:SortDirectionEnum.cs


示例18: WriteReport

        private static void WriteReport(Histogram[] histogram, string[] timeMarker)
        {
            TypeDescriptor[] typeIndexToTypeDescriptor = new TypeDescriptor[histogram[0].readNewLog.typeName.Length];

            int[] totalSize = new int[histogram.Length];
            int[] totalCount = new int[histogram.Length];
            for (int h = 0; h < histogram.Length; h++)
            {
                int[] typeSizeStacktraceToCount = histogram[h].typeSizeStacktraceToCount;

                for (int i = 0; i < typeSizeStacktraceToCount.Length; i++)
                {
                    int count = typeSizeStacktraceToCount[i];
                    if (count == 0)
                        continue;

                    int[] stacktrace = histogram[h].readNewLog.stacktraceTable.IndexToStacktrace(i);
                    int typeIndex = stacktrace[0];
                    int size = stacktrace[1];

                    if (typeIndexToTypeDescriptor[typeIndex] == null)
                        typeIndexToTypeDescriptor[typeIndex] = new TypeDescriptor(typeIndex, histogram.Length);
                    typeIndexToTypeDescriptor[typeIndex].size[h] += size*count;
                    typeIndexToTypeDescriptor[typeIndex].count[h] += count;

                    totalSize[h] += size*count;
                    totalCount[h] += count;
                }
            }

            ArrayList al = new ArrayList();
            for (int i = 0; i < typeIndexToTypeDescriptor.Length; i++)
            {
                if (typeIndexToTypeDescriptor[i] == null)
                    continue;
                al.Add(typeIndexToTypeDescriptor[i]);
            }
            al.Sort();

            Console.Write("Typename");
            for (int h = 0; h < histogram.Length; h++)
                Console.Write(",Size({0}),#Instances({1})", timeMarker[h], timeMarker[h]);
            Console.WriteLine();
            
            Console.Write("Grand total");
            for (int h = 0; h < histogram.Length; h++)
                Console.Write(",{0},{1}", totalSize[h], totalCount[h]);
            Console.WriteLine();

            foreach (TypeDescriptor td in al)
            {
                Console.Write("{0}", histogram[0].readNewLog.typeName[td.typeIndex]);
                for (int h = 0; h < histogram.Length; h++)
                    Console.Write(",{0},{1}", td.size[h], td.count[h]);
                Console.WriteLine();
            }
        }
开发者ID:jimschubert,项目名称:clr-profiler,代码行数:57,代码来源:Reports.cs


示例19: Exit

 public virtual void Exit(TypeDescriptor node)
 {
 }
开发者ID:buunguyen,项目名称:bike,代码行数:3,代码来源:EnterForWalkerGenerator.cs


示例20: TryMap

        public IEnumerable<IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes)
        {
            IFixedAbsTransactionSite fats = taSite as IFixedAbsTransactionSite;
            if (fats == null)
                yield break;

            if (instr.Name != InstructionCodes.Abs)
                yield break;

            var operandFormat = operandTypes[0].GetFixFormat();
            if (operandFormat == null)
                yield break;

            var resultFormat = resultTypes[0].GetFixFormat();
            if (resultFormat == null)
                yield break;

            if (operandFormat.FracWidth != resultFormat.FracWidth)
                yield break;

            if (operandFormat.TotalWidth != fats.Host.InputWidth)
                yield break;

            if (resultFormat.TotalWidth != fats.Host.OutputWidth)
                yield break;

            yield return new AbsMapping(fats.Host);
        }
开发者ID:venusdharan,项目名称:systemsharp,代码行数:28,代码来源:FixedAbs.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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