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


C# IConstructor类代码示例

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


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

示例1: IsReturnTypeIObservable

        public static bool IsReturnTypeIObservable(IConstructor constructor)
        {
            try
            {
                var declaredType = constructor.ReturnType as IDeclaredType;
                if (declaredType == null)
                {
                    return false;
                }

                if (declaredType.Assembly == null)
                {
                    return false;
                }

                var typeElement = constructor.GetContainingType();
                if (typeElement == null)
                {
                    return false;
                }

                return typeElement.GetSuperTypes()
                    .Select(t => t.GetClrName().FullName)
                    .Any(n => n == Constants.ObservableInterfaceName);
            }
            catch (Exception exn)
            {
                Debug.WriteLine(exn);
                return false;
            }
        }
开发者ID:oriches,项目名称:Resharper.ReactivePlugin,代码行数:31,代码来源:ConstructorHelper.cs

示例2: ConstructYamlBool

 public static object ConstructYamlBool(IConstructor ctor, Node node) {
     bool result;
     if (TryConstructYamlBool(ctor, node, out result)) {
         return result;
     }
     return null;
 }
开发者ID:bclubb,项目名称:ironruby,代码行数:7,代码来源:SafeConstructor.cs

示例3: BoundObjectCreationExpression

 public BoundObjectCreationExpression(
     IType type,
     IConstructor boundConstructor,
     List<BoundExpression> boundParameter,
     ObjectCreationExpressionSyntax expressionSyntax)
     : base(expressionSyntax, type)
 {
     BoundConstructor = boundConstructor;
     BoundParameter = boundParameter;
 }
开发者ID:lawl-dev,项目名称:Kiwi,代码行数:10,代码来源:BoundObjectCreationExpression.cs

示例4: CreateConstructorInvocation

 public MethodInvocationExpression CreateConstructorInvocation(IConstructor ctor, params Expression[] args)
 {
     MethodInvocationExpression expression = this.get_CodeBuilder().CreateConstructorInvocation(ctor);
     int index = 0;
     Expression[] expressionArray = args;
     int length = expressionArray.Length;
     while (index < length)
     {
         expression.get_Arguments().Add(expressionArray[index]);
         index++;
     }
     return expression;
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:13,代码来源:ProcessAssignmentToDuckMembers.cs

示例5: IsContructor

        public static bool IsContructor(IObjectCreationExpression creationExpression, out IConstructor constructor)
        {
            constructor = null;

            try
            {
                if (creationExpression.Reference == null)
                {
                    return false;
                }

                var resolveResult = creationExpression.Reference.Resolve();
                constructor = resolveResult.DeclaredElement as IConstructor;

                return constructor != null;
            }
            catch (Exception exn)
            {
                Debug.WriteLine(exn);
                return false;
            }
        }
开发者ID:oriches,项目名称:Resharper.ReactivePlugin,代码行数:22,代码来源:ConstructorHelper.cs

示例6: GetMappedConstructorInfo

        /// <summary>
        /// Retrieves the ConstructorInfo for a constructor as mapped on a generic type.
        /// </summary>
        private ConstructorInfo GetMappedConstructorInfo(IType targetType, IConstructor source)
        {
            ConstructorInfo ci = GetConstructorInfo(source);
            if (!ci.DeclaringType.IsGenericTypeDefinition)
            {
                // HACK: .NET Reflection doesn't allow calling
                // TypeBuilder.GetConstructor(Type, ConstructorInfo) on types that aren't generic
                // definitions, so we have to manually find the corresponding ConstructorInfo on the
                // declaring type's definition before mapping it
                Type definition = ci.DeclaringType.GetGenericTypeDefinition();
                ci = Array.Find<ConstructorInfo>(
                    definition.GetConstructors(),
                    delegate(ConstructorInfo other) { return other.MetadataToken == ci.MetadataToken; });
            }

            return TypeBuilder.GetConstructor(GetSystemType(targetType), ci);
        }
开发者ID:Bombadil77,项目名称:boo,代码行数:20,代码来源:EmitAssembly.cs

示例7: GetConstructorInfo

        ConstructorInfo GetConstructorInfo(IConstructor entity)
        {
            // If constructor is external, get its existing ConstructorInfo
            ExternalConstructor external = entity as ExternalConstructor;
            if (null != external)
            {
                return external.ConstructorInfo;
            }

            // If constructor is mapped from a generic type, get its ConstructorInfo on the constructed type
            GenericMappedConstructor mapped = entity as GenericMappedConstructor;
            if (mapped != null)
            {
                return TypeBuilder.GetConstructor(GetSystemType(mapped.DeclaringType), GetConstructorInfo((IConstructor)mapped.SourceMember));
            }

            // If constructor is internal, get its MethodBuilder
            return GetConstructorBuilder(((InternalMethod)entity).Method);
        }
开发者ID:Bombadil77,项目名称:boo,代码行数:19,代码来源:EmitAssembly.cs

示例8: ConstructYamlTimestampYMD

        public static object ConstructYamlTimestampYMD(IConstructor ctor, Node node) {
            ScalarNode scalar = node as ScalarNode;
            if (scalar == null) {
                throw new ConstructorException("can only contruct timestamp from scalar node");
            }

            Match match = YMD_REGEXP.Match(scalar.Value);
            if (match.Success) {
                int year_ymd = int.Parse(match.Groups[1].Value);
                int month_ymd = int.Parse(match.Groups[2].Value);
                int day_ymd = int.Parse(match.Groups[3].Value);

                return new DateTime(year_ymd, month_ymd, day_ymd);
            }
            throw new ConstructorException("Invalid tag:yaml.org,2002:timestamp#ymd value.");
        }
开发者ID:bclubb,项目名称:ironruby,代码行数:16,代码来源:SafeConstructor.cs

示例9: RaiseException

 public RaiseStatement RaiseException(LexicalInfo lexicalInfo, IConstructor exceptionConstructor, params Expression[] args)
 {
     Debug.Assert(TypeSystemServices.IsValidException(exceptionConstructor.DeclaringType));
     return new RaiseStatement(lexicalInfo, CreateConstructorInvocation(lexicalInfo, exceptionConstructor, args));
 }
开发者ID:0xb1dd1e,项目名称:boo,代码行数:5,代码来源:BooCodeBuilder.cs

示例10: CreateConstructorInvocation

 public MethodInvocationExpression CreateConstructorInvocation(IConstructor constructor)
 {
     MethodInvocationExpression mie = new MethodInvocationExpression();
     mie.Target = new ReferenceExpression(constructor.DeclaringType.FullName);
     mie.Target.Entity = constructor;
     mie.ExpressionType = constructor.DeclaringType;
     return mie;
 }
开发者ID:0xb1dd1e,项目名称:boo,代码行数:8,代码来源:BooCodeBuilder.cs

示例11: CreateAttribute

 public Attribute CreateAttribute(IConstructor constructor, Expression arg)
 {
     var attribute = CreateAttribute(constructor);
     attribute.Arguments.Add(arg);
     return attribute;
 }
开发者ID:0xb1dd1e,项目名称:boo,代码行数:6,代码来源:BooCodeBuilder.cs

示例12: ConstructSpecializedMap

 public static object ConstructSpecializedMap(IConstructor ctor, string pref, Node node) {
     Hash result = null;
     try {
         result = (Hash)Type.GetType(pref).GetConstructor(Type.EmptyTypes).Invoke(null);
     } catch (Exception e) {
         throw new ConstructorException("Can't construct a mapping from class: " + pref, e);
     }
     foreach (KeyValuePair<object, object> e in ctor.ConstructMapping(node)) {
         result.Add(e.Key, e.Value);
     }
     return result;
 }
开发者ID:bclubb,项目名称:ironruby,代码行数:12,代码来源:SafeConstructor.cs

示例13: ConstructSpecializedSequence

 public static object ConstructSpecializedSequence(IConstructor ctor, string pref, Node node) {
     RubyArray result = null;
     try {
         result = (RubyArray)Type.GetType(pref).GetConstructor(Type.EmptyTypes).Invoke(null);
     } catch (Exception e) {
         throw new ConstructorException("Can't construct a sequence from class: " + pref, e);
     }
     foreach (object x in ctor.ConstructSequence(node)) {
         result.Add(x);
     }
     return result;
 }
开发者ID:bclubb,项目名称:ironruby,代码行数:12,代码来源:SafeConstructor.cs

示例14: ConstructYamlBinary

 public static byte[] ConstructYamlBinary(IConstructor ctor, Node node) {
     string val = ctor.ConstructScalar(node).ToString().Replace("\r", "").Replace("\n", "");
     return Convert.FromBase64String(val);
 }
开发者ID:bclubb,项目名称:ironruby,代码行数:4,代码来源:SafeConstructor.cs

示例15: ConstructYamlFloat

 public static object ConstructYamlFloat(IConstructor ctor, Node node) {
     string value = ctor.ConstructScalar(node).ToString().Replace("_", "").Replace(",", "");
     int sign = +1;
     char first = value[0];
     if (first == '-') {
         sign = -1;
         value = value.Substring(1);
     } else if (first == '+') {
         value = value.Substring(1);
     }
     string valLower = value.ToLower();
     if (valLower == ".inf") {
         return sign == -1 ? double.NegativeInfinity : double.PositiveInfinity;
     } else if (valLower == ".nan") {
         return double.NaN;
     } else if (value.IndexOf(':') != -1) {
         string[] digits = value.Split(':');
         int bes = 1;
         double val = 0.0;
         for (int i = 0, j = digits.Length; i < j; i++) {
             val += (double.Parse(digits[(j - i) - 1]) * bes);
             bes *= 60;
         }
         return sign * val;
     } else {
         return sign * double.Parse(value);
     }
 }
开发者ID:bclubb,项目名称:ironruby,代码行数:28,代码来源:SafeConstructor.cs


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