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

C# IConstructor类代码示例

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

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



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


示例16: ConstructYamlInt

        public static object ConstructYamlInt(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);
            }
            int @base = 10;
            if (value == "0") {
                return 0;
            } else if (value.StartsWith("0b")) {
                value = value.Substring(2);
                @base = 2;
            } else if (value.StartsWith("0x")) {
                value = value.Substring(2);
                @base = 16;
            } else if (value.StartsWith("0")) {
                value = value.Substring(1);
                @base = 8;
            } else if (value.IndexOf(':') != -1) {
                string[] digits = value.Split(':');
                int bes = 1;
                int val = 0;
                for (int i = 0, j = digits.Length; i < j; i++) {
                    val += (int.Parse(digits[(j - i) - 1]) * bes);
                    bes *= 60;
                }
                return sign*val;
            }

            try {
                // LiteralParser.ParseInteger delegate handles parsing & conversion to BigInteger (if needed)
                return LiteralParser.ParseInteger(sign, value, @base);
            } catch (Exception e) {
                throw new ConstructorException(string.Format("Could not parse integer value: '{0}' (sign {1}, base {2})", value, sign, @base), e);
            }
        }
开发者ID:bclubb,项目名称:ironruby,代码行数:40,代码来源:SafeConstructor.cs


示例17: ConstructYamlTimestamp

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

            if (!match.Success) {
                return ctor.ConstructPrivateType(node);
            }

            string year_s = match.Groups[1].Value;
            string month_s = match.Groups[2].Value;
            string day_s = match.Groups[3].Value;
            string hour_s = match.Groups[4].Value;
            string min_s = match.Groups[5].Value;
            string sec_s = match.Groups[6].Value;
            string fract_s = match.Groups[7].Value;
            string utc = match.Groups[8].Value;
            string timezoneh_s = match.Groups[9].Value;
            string timezonem_s = match.Groups[10].Value;

            bool isUtc = utc == "Z" || utc == "z";

            DateTime dt = new DateTime(
                year_s != "" ? int.Parse(year_s) : 0,
                month_s != "" ? int.Parse(month_s) : 1,
                day_s != "" ? int.Parse(day_s) : 1,
                hour_s != "" ? int.Parse(hour_s) : 0,
                min_s != "" ? int.Parse(min_s) : 0,
                sec_s != "" ? int.Parse(sec_s) : 0,
                isUtc? DateTimeKind.Utc : DateTimeKind.Local
            );

            if (!string.IsNullOrEmpty(fract_s)) {
                long fract = int.Parse(fract_s);
                if (fract > 0) {
                    while (fract < 1000000) {
                        fract *= 10;
                    }
                    dt = dt.AddTicks(fract);
                }
            }

            if (!isUtc) {
                if (timezoneh_s != "" || timezonem_s != "") {
                    int zone = 0;
                    int sign = +1;
                    if (timezoneh_s != "") {
                        if (timezoneh_s.StartsWith("-")) {
                            sign = -1;
                        }
                        zone += int.Parse(timezoneh_s.Substring(1)) * 3600000;
                    }
                    if (timezonem_s != "") {
                        zone += int.Parse(timezonem_s) * 60000;
                    }
                    double utcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(dt).TotalMilliseconds;
                    dt = dt.AddMilliseconds(utcOffset - sign * zone);
                }
            }
            return dt;
        }
开发者ID:bclubb,项目名称:ironruby,代码行数:64,代码来源:SafeConstructor.cs


示例18: BindConstructorInvocation

 void BindConstructorInvocation(MethodInvocationExpression node, IConstructor ctor)
 {
     // rebind the target now we know
     // it is a constructor call
     Bind(node.Target, ctor);
     BindExpressionType(node.Target, ctor.Type);
     BindExpressionType(node, ctor.DeclaringType);
 }
开发者ID:stuman08,项目名称:boo,代码行数:8,代码来源:ProcessMethodBodies.cs


示例19: ConstructCliObject

        public static object ConstructCliObject(IConstructor ctor, string pref, Node node) {
            // TODO: should this use serialization or some more standard CLR mechanism?
            //       (it is very ad-hoc)
            // TODO: use DLR APIs instead of reflection
            try {
                Type type = Type.GetType(pref);
                object result = type.GetConstructor(Type.EmptyTypes).Invoke(null);

                foreach (KeyValuePair<object, object> e in ctor.ConstructMapping(node)) {
                    string name = e.Key.ToString();
                    name = "" + char.ToUpper(name[0]) + name.Substring(1);
                    PropertyInfo prop = type.GetProperty(name);

                    prop.SetValue(result, Convert.ChangeType(e.Value, prop.PropertyType), null);
                }
                return result;

            } catch (Exception e) {
                throw new ConstructorException("Can't construct a CLI object from class: " + pref, e);
            }
        }
开发者ID:bclubb,项目名称:ironruby,代码行数:21,代码来源:SafeConstructor.cs


示例20: ConstructYamlNull

 public static object ConstructYamlNull(IConstructor ctor, Node node) {
     return null;
 }
开发者ID:bclubb,项目名称:ironruby,代码行数:3,代码来源:SafeConstructor.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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