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

C# TypeInfo类代码示例

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

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



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

示例1: EnumDCInterfaceMembers

 private void EnumDCInterfaceMembers(TypeInfo info, EnumMembersHandler handler) {
     var generatedEntityInfo = info.FindDCXPClassInfo();
     var dcPropertyInfos = DCPropertyInfos(generatedEntityInfo);
     foreach (DCPropertyInfo dcPropertyInfo in dcPropertyInfos){
         handler(dcPropertyInfo, dcPropertyInfo.Name);
     }
 }
开发者ID:aries544,项目名称:eXpand,代码行数:7,代码来源:XpandXpoTypeInfoSource.cs


示例2: ShowDialog

        /// <summary>
        /// Prompts the user to edit a value.
        /// </summary>
        public Variant ShowDialog(Session session, NodeId nodeId)
        {
            m_session = session;
            m_nodeId = nodeId;

            #region Task #B2 - Write Value
            // generate a default value based on the data type.
            m_value = Variant.Null;
            m_sourceType = GetExpectedType(session, nodeId);

            if (m_sourceType != null)
            {
                m_value = new Variant(TypeInfo.GetDefaultValue(m_sourceType.BuiltInType), m_sourceType);
            }

            // cast the value to a string.
            ValueTB.Text = (string)TypeInfo.Cast(m_value.Value, m_value.TypeInfo, BuiltInType.String);
            #endregion

            if (ShowDialog() != DialogResult.OK)
            {
                return Variant.Null;
            }

            return m_value;
        }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:29,代码来源:WriteValueDlg.cs


示例3: ShouldSetTypePropertyWhenPassingTypeInfoToConstructor

        public void ShouldSetTypePropertyWhenPassingTypeInfoToConstructor()
        {
            var typeInfo = new TypeInfo(typeof(CustomClass));
            var dynamicObject = new DynamicObject(typeInfo);

            dynamicObject.Type.ShouldBe(typeInfo);
        }
开发者ID:6bee,项目名称:aqua-core,代码行数:7,代码来源:When_creating_dynamic_object_with_typeinfo.cs


示例4: LocalInfo

 LocalInfo(TypeInfo type, String name, int index, Label beginLabel, Label endLabel) {
     this.type = type;
     this.name = name;
     this.index = index;
     this.beginLabel = beginLabel;
     this.endLabel = endLabel;
 }
开发者ID:nagyistoce,项目名称:cnatural-language,代码行数:7,代码来源:CodeGenerator.stab.cs


示例5: Resolve

        public override FlatOperand Resolve(ExpressionSyntax expression, ArgumentListSyntax argumentList, TypeInfo result_type, SymbolInfo si, FlatOperand into_lvalue, Function function, List<FlatStatement> instructions)
        {
            FlatOperand fop_subject;
            if (expression is IdentifierNameSyntax)
            {
                // typeof this
                fop_subject = FlatOperand.ThisRef(FlatValue.FromType(result_type.ConvertedType));
            }
            else if (expression is MemberAccessExpressionSyntax)
            {
                MemberAccessExpressionSyntax meas = (MemberAccessExpressionSyntax)expression;

                fop_subject = function.ResolveExpression(meas.Expression, null, instructions);
            }
            else
            {
                throw new NotImplementedException("GetMetaTable on expression type " + expression.GetType().ToString());
            }

            if (into_lvalue == null)
            {
                FlatOperand fop_register = function.AllocateRegister("");
                into_lvalue = fop_register.GetLValue(function, instructions);
            }
            instructions.Add(FlatStatement.GETMETATABLE(into_lvalue, fop_subject));
            return into_lvalue.AsRValue(FlatValue.Table());
        }
开发者ID:LaxLacks,项目名称:ls2csc,代码行数:27,代码来源:Intrinsics.cs


示例6: It_can_create_a_deep_clone_of_itself

        public void It_can_create_a_deep_clone_of_itself()
        {
            var type1 = new TypeInfo
                        {
                            Name = "MyType",
                            Kind = TypeKind.Class,
                            Obsolete = true,
                            ObsoleteMessage = "I'm obsolete!",
                            Members =
                                {
                                    new MemberInfo
                                    {
                                        Changes = { new MemberChangeInfo() }
                                    }
                                },
                            Changes =
                                {
                                    new TypeChangeInfo()
                                }
                        };

            var type2 = type1.Clone();

            Assert.AreNotSame(type1, type2);
            Assert.AreEqual(type1.Name, type2.Name);
            Assert.AreEqual(type1.Kind, type2.Kind);
            Assert.AreEqual(type1.Obsolete, type2.Obsolete);
            Assert.AreEqual(type1.ObsoleteMessage, type2.ObsoleteMessage);
            Assert.AreNotSame(type1.Members, type2.Members);
            Assert.AreNotSame(type1.Members.Single(), type2.Members.Single());
            Assert.AreNotSame(type1.Members.Single().Changes.Single(), type2.Members.Single().Changes.Single());
            Assert.AreNotSame(type1.Changes, type2.Changes);
            Assert.AreNotSame(type1.Changes.Single(), type2.Changes.Single());
        }
开发者ID:nikkin,项目名称:NChanges,代码行数:34,代码来源:Describe_TypeInfo.cs


示例7: It_detects_Obsolete_attributes

        public void It_detects_Obsolete_attributes()
        {
            var typeInfo = new TypeInfo();

            typeInfo.ReadType(Compiler.GetType(
            @"namespace MyNamespace
            {
            [System.Obsolete(""This class is obsolete!"")]
            public class MyClass
            {
            [System.Obsolete(""This constructor is obsolete!"")]
            public MyClass() { }
            [System.Obsolete(""This method is obsolete!"")]
            public void MyMethod() { }
            [System.Obsolete(""This property is obsolete!"")]
            public int MyProperty { get; set; }
            [System.Obsolete(""This event is obsolete!"")]
            public event System.EventHandler MyEvent;
            [System.Obsolete(""This field is obsolete!"")]
            public int MyField;
            }
            }"));
            Assert.IsTrue(typeInfo.Obsolete);
            Assert.AreEqual("This class is obsolete!", typeInfo.ObsoleteMessage);
            Assert.IsTrue(typeInfo.Members.Single(m => m.Name == ".ctor").Obsolete);
            Assert.AreEqual("This constructor is obsolete!", typeInfo.Members.Single(m => m.Name == ".ctor").ObsoleteMessage);
            Assert.IsTrue(typeInfo.Members.Single(m => m.Name == "MyMethod").Obsolete);
            Assert.AreEqual("This method is obsolete!", typeInfo.Members.Single(m => m.Name == "MyMethod").ObsoleteMessage);
            Assert.IsTrue(typeInfo.Members.Single(m => m.Name == "MyProperty").Obsolete);
            Assert.AreEqual("This property is obsolete!", typeInfo.Members.Single(m => m.Name == "MyProperty").ObsoleteMessage);
            Assert.IsTrue(typeInfo.Members.Single(m => m.Name == "MyEvent").Obsolete);
            Assert.AreEqual("This event is obsolete!", typeInfo.Members.Single(m => m.Name == "MyEvent").ObsoleteMessage);
            Assert.IsTrue(typeInfo.Members.Single(m => m.Name == "MyField").Obsolete);
            Assert.AreEqual("This field is obsolete!", typeInfo.Members.Single(m => m.Name == "MyField").ObsoleteMessage);
        }
开发者ID:nikkin,项目名称:NChanges,代码行数:35,代码来源:Describe_TypeInfo.cs


示例8: Create

        public static TypeInfo Create(Type rootType, Func<Type, IEntityMetaDataProvider> provider)
        {
            if (null == rootType)
                throw new ArgumentNullException(nameof(rootType));
            if (null == provider)
                throw new ArgumentNullException(nameof(provider));

            TypeInfo typeInfo = new TypeInfo();

            typeInfo.Id = rootType.FullName; //NosQL Id.

            typeInfo.Pageable = rootType.GetCustomAttribute<GridPageableAttribute>();


            typeInfo.Sortable = rootType.GetCustomAttribute<GridSortableAttribute>();

            typeInfo.Filterable = rootType.GetCustomAttribute<GridFilterableAttribute>();

            typeInfo.Editable = rootType.GetCustomAttribute<GridEditableAttribute>();

            GridAttribute ga = rootType.GetCustomAttribute<GridAttribute>();
            if (null != ga)
            {
                typeInfo.Groupable = ga.Groupable;
                typeInfo.Height = ga.Height;
            }


            LoadFields(typeInfo, null, rootType, provider);

            return typeInfo;
        }
开发者ID:mehmetgoren,项目名称:AppX.UI,代码行数:32,代码来源:TypeInfo.Loader.cs


示例9: ExpressionInfo

 ExpressionInfo(TypeInfo type, Object value) {
     this.Type = type;
     this.Value = value;
     this.IsConstant = true;
     this.BoxingKind = BoxingKind.None;
     this.Negate = true;
 }
开发者ID:nagyistoce,项目名称:cnatural-language,代码行数:7,代码来源:ExpressionInfo.stab.cs


示例10: CheckSemantic

        public override void CheckSemantic(Scope scope, List<Error> errors)
        {
            countLoop++;
            //chekeo la semantica de la expr inicial
            ExprFor.CheckSemantic(scope, errors);

            //si el tipo de retorno no es int lanzo un error
            if (ExprFor.ReturnType!= null && ExprFor.ReturnType.BaseType.Name != "int")
                errors.Add(new Error(Row, Col, "The first expression of <for> must be an int"));

            //chekeo la semantica de la expr final
            ExprTo.CheckSemantic(scope, errors);
            //si no tiene errores esa expr

            //si el tipo de retorno no es int lanzo un error
            if (ExprTo.ReturnType != null && ExprTo.ReturnType.BaseType.Name != "int")
                errors.Add(new Error(Row, Col, "The To'expression of <for> must be an int"));

            //creo un nuevo scope
            Scope for_scope = new Scope(scope);
            //agrego la var de ciclo
            for_scope.Variables.Add(IdLoop, new VarInfo(IdLoop, scope.ExistType("int")));

            for_scope.IdLoop = IdLoop;

            ExprDo.CheckSemantic(for_scope, errors);

            ReturnType = new TypeInfo("void", null, TypeDecl.Base);
            countLoop--;
        }
开发者ID:oisbel,项目名称:TigerCompiler,代码行数:30,代码来源:ForNode.cs


示例11: ConventionInfo

 public ConventionInfo()
 {
     Source = new TypeInfo();
     Target = new TypeInfo();
     SourceProp = new PropInfo();
     TargetProp = new PropInfo();
 }
开发者ID:jpomez,项目名称:ValueInjecter,代码行数:7,代码来源:ConventionInjection.cs


示例12: GetTypeInfo

        public TypeInfo GetTypeInfo(Type type)
        {
            if (!_typeInfos.ContainsKey(type))
            {
                var typeInfo = new TypeInfo
                    {
                        Id = _typeInfos.Count,
                        TypeName = type.AssemblyQualifiedName,
                        IsEnumerable = type.IsImplOf<IEnumerable>()
                    };

                if (!typeInfo.IsEnumerable)
                {
                    var propertyInfos = type.GetProperties();
                    var propertyNames = new SimpleList<string>();
                    foreach (var propertyInfo in propertyInfos)
                    {
                        if (!IsAValidProperty(propertyInfo)) continue;
                        propertyNames.Add(propertyInfo.Name);
                    }
                    typeInfo.PropertyNames = propertyNames;
                }

                _typeInfos.Add(type, typeInfo);
                return typeInfo;
            }
            return _typeInfos[type];
        }
开发者ID:ahmedowsky,项目名称:Ahmedowsky,代码行数:28,代码来源:TypeEnumerator.cs


示例13: TypeInfo_CustomAttributes

 public static void TypeInfo_CustomAttributes(TypeInfo typeInfo)
 {
     String typeName = typeInfo.NameString();
     if (typeName == null)
         return;
     ReflectionEventSource.Log.TypeInfo_CustomAttributes(typeName);
 }
开发者ID:noahfalk,项目名称:corert,代码行数:7,代码来源:ReflectionTrace.Public.Events.cs


示例14: When_resolving_two_types_with_same_name

        public When_resolving_two_types_with_same_name()
        {
            var a = new A { Int32Value = 0, StringValue = "" };
            var b = new { Int32Value = 0, StringValue = "" };

            var typeInfoA = new TypeInfo(a.GetType());
            var typeInfoB = new TypeInfo(b.GetType());

            typeInfoA.Name = "TestTypeName";
            typeInfoB.Name = "TestTypeName";

            typeInfoA.Namespace = "TestNamespace";
            typeInfoB.Namespace = "TestNamespace";

            typeInfoA.DeclaringType = null;
            typeInfoB.DeclaringType = null;

            var typeResolver = new TypeResolver();

            resolvedTypeA1 = typeResolver.ResolveType(typeInfoA);
            resolvedTypeB1 = typeResolver.ResolveType(typeInfoB);

            resolvedTypeA2 = typeResolver.ResolveType(typeInfoA);
            resolvedTypeB2 = typeResolver.ResolveType(typeInfoB);
        }
开发者ID:6bee,项目名称:aqua-core,代码行数:25,代码来源:When_resolving_two_types_with_same_name.cs


示例15: CheckSemantic

        public override void CheckSemantic(Scope scope, List<Error> errors)
        {
            string id_var = "";
            //chekeo la semantica del lvalue
            LeftExpr.CheckSemantic(scope, errors);
            TypeInfo t = LeftExpr.ReturnType;

            //en el caso de q sea una variable guardo
            //su valor para despues compararlo con el id del ciclo
            if (LeftExpr is VariableNode)
                id_var = ((VariableNode)LeftExpr).Value;

            //chekeo la semantica del rvalue
            RigthExpr.CheckSemantic(scope, errors);
            TypeInfo t1 = RigthExpr.ReturnType;

            if (t != null && t1 != null && t.Name != t1.Name)
            {
                if (t1.Name == "nil")
                {
                    if (t.Name == "int")
                        errors.Add(new Error(Row, Col, string.Format("Cannot assign nil to an int")));
                }
                else if(t1.Name == "void")
                    errors.Add(new Error(Row, Col, string.Format("The expression that try assign to \"{0}\" not return value", t.Name)));
                else
                    errors.Add(new Error(Row, Col, string.Format("Cannot asssign  \"{0}\" to  \"{1}\"", t1.Name, t.Name)));
            }
            else
            {
                if (countLoop >0  && id_var == scope.IdLoop)
                    errors.Add(new Error(Row, Col, string.Format("Cannot assign any value to variable \"{0}\" of <for>", scope.IdLoop)));
            }
            ReturnType = new TypeInfo("void", null, TypeDecl.Base);
        }
开发者ID:oisbel,项目名称:TigerCompiler,代码行数:35,代码来源:AssingmentNode.cs


示例16: MapDestinationCtorToSource

        private bool MapDestinationCtorToSource(TypeMap typeMap, ConstructorInfo destCtor, TypeInfo sourceTypeInfo,
                                                IMappingOptions options)
        {
            var parameters = new List<ConstructorParameterMap>();
            var ctorParameters = destCtor.GetParameters();

            if (ctorParameters.Length == 0 || !options.ConstructorMappingEnabled)
                return false;

            foreach (var parameter in ctorParameters)
            {
                var members = new LinkedList<MemberInfo>();

                if (!MapDestinationPropertyToSource(members, sourceTypeInfo, parameter.Name, options))
                    return false;

                var resolvers = members.Select(mi => mi.ToMemberGetter());

                var param = new ConstructorParameterMap(parameter, resolvers.ToArray());

                parameters.Add(param);
            }

            typeMap.AddConstructorMap(destCtor, parameters);

            return true;
        }
开发者ID:EdsonF,项目名称:AutoMapper,代码行数:27,代码来源:TypeMapFactory.cs


示例17: DataContract2ClassBuilder

        public DataContract2ClassBuilder(string ns, Command cmd, DataTable dt)
            : base(ns, cmd)
        {
            this.dt = dt;

            foreach (DataColumn column in dt.Columns)
            {
                TypeInfo ty = new TypeInfo { type = column.DataType };
                foreach (DataRow row in dt.Rows)
                {
                    if (row[column] == DBNull.Value)
                        ty.Nullable = true;
                    break;
                }

                dict.Add(column, ty);
            }

            builder.AddUsing("System");
            builder.AddUsing("System.Collections.Generic");
            builder.AddUsing("System.Data");
            builder.AddUsing("System.Linq");
            builder.AddUsing("Sys.Data");

            AddOptionalUsing();
        }
开发者ID:fjiang2,项目名称:sqlcon,代码行数:26,代码来源:DataContract2ClassBuilder.cs


示例18: isCallingResourceManagerCtor

        static bool isCallingResourceManagerCtor(IList<Instruction> instrs, int ldstrIndex, TypeInfo typeInfo)
        {
            try {
                int index = ldstrIndex + 1;

                var ldtoken = instrs[index++];
                if (ldtoken.OpCode.Code != Code.Ldtoken)
                    return false;
                if (!new SigComparer().Equals(typeInfo.type.TypeDef, ldtoken.Operand as ITypeDefOrRef))
                    return false;

                if (!checkCalledMethod(instrs[index++], "System.Type", "(System.RuntimeTypeHandle)"))
                    return false;
                if (!checkCalledMethod(instrs[index++], "System.Reflection.Assembly", "()"))
                    return false;

                var newobj = instrs[index++];
                if (newobj.OpCode.Code != Code.Newobj)
                    return false;
                if (newobj.Operand.ToString() != "System.Void System.Resources.ResourceManager::.ctor(System.String,System.Reflection.Assembly)")
                    return false;

                return true;
            }
            catch (ArgumentOutOfRangeException) {
                return false;
            }
            catch (IndexOutOfRangeException) {
                return false;
            }
        }
开发者ID:GodLesZ,项目名称:ConfuserDeobfuscator,代码行数:31,代码来源:ResourceRenamer.cs


示例19: GetNextTypeInfo

 internal static TypeInfo GetNextTypeInfo(Type initialArg, TypeInfo curTypeInfo)
 {
     lock (_DelegateCache)
     {
         return NextTypeInfo(initialArg, curTypeInfo);
     }
 }
开发者ID:alessandromontividiu03,项目名称:corefx,代码行数:7,代码来源:DelegateHelpers.Generated.cs


示例20: TypeMap

 public TypeMap(TypeInfo sourceType, TypeInfo destinationType, MemberList memberList)
 {
     _sourceType = sourceType;
     _destinationType = destinationType;
     Profile = ConfigurationStore.DefaultProfileName;
     ConfiguredMemberList = memberList;
 }
开发者ID:yaroslavya,项目名称:AutoMapper,代码行数:7,代码来源:TypeMap.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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