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


C# TypeDescriptor类代码示例

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


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


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