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


C# RubyContext.GetClassOf方法代码示例

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


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

示例1: InitializeCopy

        public static object InitializeCopy(RubyContext/*!*/ context, object self, object source) {
            RubyClass selfClass = context.GetClassOf(self);
            RubyClass sourceClass = context.GetClassOf(source);
            if (sourceClass != selfClass) {
                throw RubyExceptions.CreateTypeError("initialize_copy should take same class object");
            }
            
            if (context.IsObjectFrozen(self)) {
                throw RubyExceptions.CreateTypeError(String.Format("can't modify frozen {0}", selfClass.Name));
            }

            return self;
        }
开发者ID:aceptra,项目名称:ironruby,代码行数:13,代码来源:KernelOps.cs

示例2: Include

        public static RubyClass/*!*/ Include(RubyContext/*!*/ context, object/*!*/ self, params RubyModule[]/*!*/ modules) {
            ContractUtils.RequiresNotNullItems(modules, "modules");
            RubyUtils.RequireNonClasses(modules);

            RubyClass result = context.GetClassOf(self);
            result.IncludeModules(modules);
            return result;
        }
开发者ID:mscottford,项目名称:ironruby,代码行数:8,代码来源:SingletonOps.cs

示例3: TagUri

 public static MutableString/*!*/ TagUri(RubyContext/*!*/ context, object self) {
     var result = MutableString.Create(Tags.RubyObject, context.GetIdentifierEncoding());
     var selfClass = context.GetClassOf(self);
     if (selfClass != context.ObjectClass) {
         return result.Append(':').Append(context.GetClassName(self));
     } else {
         return result;
     }
 }
开发者ID:rudimk,项目名称:dlr-dotnet,代码行数:9,代码来源:BuiltinsOps.cs

示例4: GetClassObsolete

 public static RubyClass/*!*/ GetClassObsolete(RubyContext/*!*/ context, object self) {
     context.ReportWarning("Object#type will be deprecated; use Object#class");
     return context.GetClassOf(self);
 }
开发者ID:aceptra,项目名称:ironruby,代码行数:4,代码来源:KernelOps.cs

示例5: Include

 public static RubyClass Include(RubyContext/*!*/ context, object/*!*/ self, params RubyModule[]/*!*/ modules)
 {
     RubyClass result = context.GetClassOf(self);
     result.IncludeModules(modules);
     return result;
 }
开发者ID:TerabyteX,项目名称:main,代码行数:6,代码来源:SingletonOps.cs

示例6: CreateResultArray

        private static IList/*!*/ CreateResultArray(CallSiteStorage<Func<CallSite, RubyContext, RubyClass, object>>/*!*/ allocateStorage,
            RubyContext/*!*/ context, IList/*!*/ list) {
            
            // RubyArray:
            var array = list as RubyArray;
            if (array != null) {
                return array.CreateInstance();
            }
            
            // interop - call a default ctor to get an instance:
            var allocate = allocateStorage.GetCallSite("allocate", 0);
            var cls = context.GetClassOf(list);
            var result = allocate.Target(allocate, context, cls) as IList;
            if (result != null) {
                return result;
            }

            throw RubyExceptions.CreateTypeError(String.Format("{0}#allocate should return IList", cls.Name));
        }
开发者ID:tnachen,项目名称:ironruby,代码行数:19,代码来源:IListOps.cs

示例7: Inspect

 public static MutableString/*!*/ Inspect(RubyContext/*!*/ context, BigDecimal/*!*/ self) {
     MutableString str = MutableString.CreateMutable();
     str.AppendFormat("#<{0}:", context.GetClassOf(self).Name);
     RubyUtils.AppendFormatHexObjectId(str, RubyUtils.GetObjectId(context, self));
     str.AppendFormat(",'{0}',", self.ToString(10));
     str.AppendFormat("{0}({1})>", self.PrecisionDigits.ToString(), self.MaxPrecisionDigits.ToString());
     return str;
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:8,代码来源:BigDecimalOps.cs

示例8: MakeCoercionError

 public static Exception/*!*/ MakeCoercionError(RubyContext/*!*/ context, object self, object other) {
     string selfClass = context.GetClassOf(self).Name;
     string otherClass = context.GetClassOf(other).Name;
     return CreateTypeError("{0} can't be coerced into {1}", selfClass, otherClass);
 }
开发者ID:cleydson,项目名称:ironruby,代码行数:5,代码来源:RubyExceptions.cs

示例9: ToSuperClass

        private static RubyClass/*!*/ ToSuperClass(RubyContext/*!*/ ec, object superClassObject) {
            if (superClassObject != null) {
                RubyClass superClass = superClassObject as RubyClass;
                if (superClass == null) {
                    throw RubyExceptions.CreateTypeError(String.Format("superclass must be a Class ({0} given)", ec.GetClassOf(superClassObject).Name));
                }

                if (superClass.IsSingletonClass) {
                    throw RubyExceptions.CreateTypeError("can't make subclass of virtual class");
                }

                return superClass;
            } else {
                return ec.ObjectClass;
            }
        }
开发者ID:mscottford,项目名称:ironruby,代码行数:16,代码来源:RubyUtils.cs

示例10: GetMethod

 public static RubyMethod/*!*/ GetMethod(RubyContext/*!*/ context, object self, [DefaultProtocol, NotNull]string/*!*/ name) {
     RubyMemberInfo info = context.ResolveMethod(self, name, VisibilityContext.AllVisible).Info;
     if (info == null) {
         throw RubyExceptions.CreateUndefinedMethodError(context.GetClassOf(self), name);
     }
     return new RubyMethod(self, info, name);
 }
开发者ID:aceptra,项目名称:ironruby,代码行数:7,代码来源:KernelOps.cs

示例11: CreateResultArray

 private static IList/*!*/ CreateResultArray(RubyContext/*!*/ context, IList/*!*/ self) {
     return _CreateArraySite.Target(_CreateArraySite, context, context.GetClassOf(self));
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:3,代码来源:IListOps.cs

示例12: MakeTime

 private static DateTime MakeTime(RubyContext/*!*/ context, object obj) {
     if (obj == null) {
         return DateTime.Now;
     } else if (obj is DateTime) {
         return (DateTime)obj;
     } else if (obj is int) {
         return TimeOps.Create(typeof(RubyFileOps), (int)obj);
     } else {
         string name = context.GetClassOf(obj).Name;
         throw RubyExceptions.CreateTypeConversionError(name, "time");
     }
 }
开发者ID:m4dc4p,项目名称:ironruby,代码行数:12,代码来源:FileOps.cs

示例13: MakeComparisonError

 public static Exception/*!*/ MakeComparisonError(RubyContext/*!*/ context, object self, object other, Exception x) {
     string selfClass = context.GetClassOf(self).Name;
     string otherClass = context.GetClassOf(other).Name;
     return RubyExceptions.CreateArgumentError("comparison of " + selfClass+ " with " + otherClass + " failed", x);
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:5,代码来源:RubyExceptions.cs

示例14: Coerce

        public static RubyArray Coerce(ConversionStorage<double>/*!*/ tof1, ConversionStorage<double>/*!*/ tof2, 
            RubyContext/*!*/ context, object self, object other) {

            if (context.GetClassOf(self) == context.GetClassOf(other)) {
                return RubyOps.MakeArray2(other, self);
            }

            var site1 = tof1.GetSite(ConvertToFAction.Instance);
            var site2 = tof2.GetSite(ConvertToFAction.Instance);
            return RubyOps.MakeArray2(site1.Target(site1, context, other), site2.Target(site2, context, self));
        }
开发者ID:tnachen,项目名称:ironruby,代码行数:11,代码来源:Numeric.cs

示例15: ObjectToMutableString

        public static MutableString/*!*/ ObjectToMutableString(RubyContext/*!*/ context, object obj) {
            using (IDisposable handle = RubyUtils.InfiniteInspectTracker.TrackObject(obj)) {
                if (handle == null) {
                    return MutableString.Create("...");
                }

                MutableString str = MutableString.CreateMutable();
                str.Append("#<");
                str.Append(context.GetClassOf(obj).Name);

                // Ruby prints 2*object_id for objects
                str.Append(':');
                AppendFormatHexObjectId(str, GetObjectId(context, obj));

                // display instance variables
                RubyInstanceData data = context.TryGetInstanceData(obj);
                if (data != null) {
                    var vars = data.GetInstanceVariablePairs();
                    bool first = true;
                    foreach (KeyValuePair<string, object> var in vars) {
                        if (first) {
                            str.Append(" ");
                            first = false;
                        } else {
                            str.Append(", ");
                        }
                        str.Append(var.Key);
                        str.Append("=");
                        str.Append(RubySites.Inspect(context, var.Value));
                    }
                }
                str.Append(">");

                return str;
            }
        }
开发者ID:mscottford,项目名称:ironruby,代码行数:36,代码来源:RubyUtils.cs


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