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


C# RubyClass.GetUnderlyingSystemType方法代码示例

本文整理汇总了C#中IronRuby.Builtins.RubyClass.GetUnderlyingSystemType方法的典型用法代码示例。如果您正苦于以下问题:C# RubyClass.GetUnderlyingSystemType方法的具体用法?C# RubyClass.GetUnderlyingSystemType怎么用?C# RubyClass.GetUnderlyingSystemType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IronRuby.Builtins.RubyClass的用法示例。


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

示例1: CreateMissingDefaultConstructorError

        public static Exception/*!*/ CreateMissingDefaultConstructorError(RubyClass/*!*/ rubyClass, string/*!*/ initializerOwnerName) {
            Debug.Assert(rubyClass.IsRubyClass);

            Type baseType = rubyClass.GetUnderlyingSystemType().BaseType;
            Debug.Assert(baseType != null);

            return CreateTypeError("can't allocate class `{1}' that derives from type `{0}' with no default constructor;" +
                " define {1}#new singleton method instead of {2}#initialize",
                rubyClass.Context.GetTypeName(baseType, true), rubyClass.Name, initializerOwnerName
            );
        }
开发者ID:cleydson,项目名称:ironruby,代码行数:11,代码来源:RubyExceptions.cs

示例2: CreateObjectAndSetIvars

            public static object/*!*/ CreateObjectAndSetIvars(RubyClass theClass, IDictionary<string, object> attributes = null) {
                Assert.NotNull(theClass);

                object result = null;

                BindingFlags bindingFlags = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance;
                ConstructorInfo ci;

                Type baseType = theClass.GetUnderlyingSystemType();
                if (baseType == typeof(RubyStruct)) {
                    return CreateStruct(theClass, baseType, attributes); // we never set ivars on structs
                } else if (typeof(Range).IsAssignableFrom(baseType)) {
                    result = CreateRange(theClass, baseType, attributes);
                } else if (typeof(Exception).IsAssignableFrom(baseType)) {
                    result = CreateException(theClass, baseType, attributes);
                } else if (IsAvailable(ci = baseType.GetConstructor(bindingFlags, null, Type.EmptyTypes, null))) {
                    result = ci.Invoke(new object[0] { });
                } else if (IsAvailable(ci = baseType.GetConstructor(bindingFlags, null, _ccTypes1, null))) {
                    result = ci.Invoke(new object[1] { theClass });
                } else if (IsAvailable(ci = baseType.GetConstructor(bindingFlags, null, _ccTypes2, null))) {
                    result = ci.Invoke(new object[1] { theClass.Context });
                } else {
                    string message = String.Format("Class {0} does not have a valid constructor", theClass.Name);
                    throw new NotSupportedException(message);
                }

                if (attributes != null) {
                    foreach (var kv in attributes) {
                        theClass.Context.SetInstanceVariable(result, kv.Key, kv.Value);
                    }
                }

                return result;
            }
开发者ID:rafacv,项目名称:iron_languages,代码行数:34,代码来源:Marshal.cs

示例3: CreateNew

        public static Proc/*!*/ CreateNew(CallSiteStorage<Func<CallSite, Proc, Proc, object>>/*!*/ storage,
            RubyClass/*!*/ self, Proc/*!*/ proc) {
            Assert.NotNull(storage, self, proc);

            // an instance of Proc class, the identity is preserved:
            if (self.GetUnderlyingSystemType() == typeof(Proc)) {
                return proc;
            }

            // an instance of a Proc subclass:
            var result = new Proc.Subclass(self, proc);

            var initialize = storage.GetCallSite("initialize", new RubyCallSignature(0, RubyCallFlags.HasImplicitSelf | RubyCallFlags.HasBlock));

            // a call to the initializer with a block:
            object initResult = null;
            do {
                // a new proc is created each iteration (even if a subclass is passed in, the Proc class is created):
                var argProc = proc.Create(proc);

                try {
                    initResult = initialize.Target(initialize, proc, argProc);
                } catch (EvalUnwinder u) {
                    initResult = u.ReturnValue;
                }

                Debug.Assert(proc != argProc, "retry doesn't propagate to the caller");
            } while (RubyOps.IsRetrySingleton(initResult));

            return result;
        }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:31,代码来源:ProcOps.cs

示例4: CreateVector

        public static object/*!*/ CreateVector(ConversionStorage<Union<IList, int>>/*!*/ toAryToInt, BlockParam block, RubyClass/*!*/ self,
            [NotNull]object/*!*/ arrayOrSize) {

            var elementType = self.GetUnderlyingSystemType().GetElementType();
            Debug.Assert(elementType != null);

            var site = toAryToInt.GetSite(CompositeConversionAction.Make(self.Context, CompositeConversion.ToAryToInt));
            var union = site.Target(site, arrayOrSize);

            if (union.First != null) {
                // block ignored
                return CreateVectorInternal(self.Context, elementType, union.First);
            } else if (block != null) {
                return PopulateVector(self.Context, CreateVectorInternal(elementType, union.Second), block);
            } else {
                return CreateVectorInternal(elementType, union.Second);
            }
        }
开发者ID:teejayvanslyke,项目名称:ironruby,代码行数:18,代码来源:RubyOps.cs

示例5: CreateVectorWithValues

        public static Array/*!*/ CreateVectorWithValues(RubyClass/*!*/ self, [DefaultProtocol]int size, object value) {
            var elementType = self.GetUnderlyingSystemType().GetElementType();
            Debug.Assert(elementType != null);

            var result = CreateVectorInternal(elementType, size);
            for (int i = 0; i < size; i++) {
                SetVectorItem(self.Context, result, i, value);
            }
            return result;
        }
开发者ID:teejayvanslyke,项目名称:ironruby,代码行数:10,代码来源:RubyOps.cs

示例6: CreateNew

        public static Proc/*!*/ CreateNew(RubyClass/*!*/ self, Proc/*!*/ proc) {
            Assert.NotNull(self, proc);

            // an instance of Proc class, the identity is preserved:
            if (self.GetUnderlyingSystemType() == typeof(Proc)) {
                return proc;
            }

            // an instance of a Proc subclass:
            var result = new Proc.Subclass(self, proc);

            // a call to the initializer with a block:
            object initResult = null;
            do {
                // a new proc is created each iteration (even if a subclass is passed in, the Proc class is created):
                var argProc = proc.Create(proc);

                try {
                    initResult = _InitializeSite.Target(_InitializeSite, self.Context, proc, argProc);
                } catch (EvalUnwinder u) {
                    initResult = u.ReturnValue;
                }

                Debug.Assert(proc != argProc, "retry doesn't propagate to the caller");
            } while (RubyOps.IsRetrySingleton(initResult));

            return result;
        }
开发者ID:mscottford,项目名称:ironruby,代码行数:28,代码来源:ProcOps.cs

示例7: CreateNew

        public static object CreateNew(CallSiteStorage<Func<CallSite, object, object, object>>/*!*/ storage, 
            BlockParam block, RubyClass/*!*/ self) {

            if (block == null) {
                throw RubyExceptions.CreateArgumentError("tried to create Proc object without a block");
            }

            var proc = block.Proc;

            // an instance of Proc class, the identity is preserved:
            if (self.GetUnderlyingSystemType() == typeof(Proc)) {
                return proc;
            }

            // an instance of a Proc subclass:
            var result = new Proc.Subclass(self, proc);

            // propagate retry and return control flow:
            var initialize = storage.GetCallSite("initialize", new RubyCallSignature(0, RubyCallFlags.HasImplicitSelf | RubyCallFlags.HasBlock));
            object initResult = initialize.Target(initialize, result, block.Proc);
            if (initResult is BlockReturnResult) {
                return initResult;
            }

            return result;
        }
开发者ID:kevinkeeney,项目名称:ironruby,代码行数:26,代码来源:ProcOps.cs

示例8: CreateObject

        public static object/*!*/ CreateObject(RubyClass/*!*/ theClass) {
            Assert.NotNull(theClass);

            Type baseType = theClass.GetUnderlyingSystemType();
            if (baseType == typeof(RubyStruct)) {
                return RubyStruct.Create(theClass);
            }

            object result;
            BindingFlags bindingFlags = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance;
            ConstructorInfo ci;
            if (IsAvailable(ci = baseType.GetConstructor(bindingFlags, null, Type.EmptyTypes, null))) {
                result = ci.Invoke(new object[0] { });
            } else if (IsAvailable(ci = baseType.GetConstructor(bindingFlags, null, _ccTypes1, null))) {
                result = ci.Invoke(new object[1] { theClass });
            } else if (IsAvailable(ci = baseType.GetConstructor(bindingFlags, null, _ccTypes2, null))) {
                result = ci.Invoke(new object[1] { theClass.Context });
            } else {
                string message = String.Format("Class {0} does not have a valid constructor", theClass.Name);
                throw new NotSupportedException(message);
            }
            return result;
        }
开发者ID:mscottford,项目名称:ironruby,代码行数:23,代码来源:RubyUtils.cs


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