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


C# IAttributesCollection类代码示例

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


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

示例1: StructType

            public StructType(CodeContext/*!*/ context, string name, PythonTuple bases, IAttributesCollection members)
                : base(context, name, bases, members) {

                foreach (PythonType pt in ResolutionOrder) {
                    StructType st = pt as StructType;
                    if (st != this && st != null) {
                        st.EnsureFinal();
                    }

                    UnionType ut = pt as UnionType;
                    if (ut != null) {
                        ut.EnsureFinal();
                    }
                }

                object pack;
                if (members.TryGetValue(SymbolTable.StringToId("_pack_"), out pack)) {
                    if (!(pack is int) || ((int)pack < 0)) {
                        throw PythonOps.ValueError("pack must be a non-negative integer");
                    }
                    _pack = (int)pack;
                }

                object fields;
                if (members.TryGetValue(SymbolTable.StringToId("_fields_"), out fields)) {
                    SetFields(fields);
                }

                // TODO: _anonymous_
            }
开发者ID:joshholmes,项目名称:ironruby,代码行数:30,代码来源:StructType.cs

示例2: GetNewType

        public static Type GetNewType(string typeName, PythonTuple bases, IAttributesCollection dict) {
            if (bases == null) bases = PythonTuple.EMPTY;
            // we're really only interested in the "correct" base type pulled out of bases
            // and any slot information contained in dict
            // other info might be used for future optimizations

            NewTypeInfo typeInfo = GetTypeInfo(typeName, bases, GetSlots(dict));

            if (typeInfo.BaseType.IsValueType)
                throw PythonOps.TypeError("cannot derive from {0} because it is a value type", typeInfo.BaseType.FullName);
            if (typeInfo.BaseType.IsSealed)
                throw PythonOps.TypeError("cannot derive from {0} because it is sealed", typeInfo.BaseType.FullName);

            Type ret = _newTypes.GetOrCreateValue(typeInfo,
                delegate() {
                    if (typeInfo.InterfaceTypes.Count == 0 && typeInfo.Slots == null) {
                        // types that the have DynamicBaseType attribute can be used as NewType's directly, no 
                        // need to create a new type unless we're adding interfaces or slots...
                        object[] attrs = typeInfo.BaseType.GetCustomAttributes(typeof(DynamicBaseTypeAttribute), false);
                        if (attrs.Length > 0) {
                            return typeInfo.BaseType;
                        }
                    }

                    // creation code                    
                    return GetTypeMaker(bases, typeInfo).CreateNewType();
                });
            
            OptimizedScriptCode.InitializeFields(ret, true);

            return ret;
        }
开发者ID:octavioh,项目名称:ironruby,代码行数:32,代码来源:NewTypeMaker.cs

示例3: UnionType

            public UnionType(CodeContext/*!*/ context, string name, PythonTuple bases, IAttributesCollection members)
                : base(context, name, bases, members) {

                object fields;
                if (members.TryGetValue(SymbolTable.StringToId("_fields_"), out fields)) {
                    SetFields(fields);
                }
            }
开发者ID:xerxesb,项目名称:ironruby,代码行数:8,代码来源:UnionType.cs

示例4: FormatString

        /// <summary>
        /// Runs the formatting operation on the given format and keyword arguments
        /// </summary>
        public static string/*!*/ FormatString(PythonContext/*!*/ context, string/*!*/ format, PythonTuple/*!*/ args, IAttributesCollection/*!*/ kwArgs) {
            ContractUtils.RequiresNotNull(context, "context");
            ContractUtils.RequiresNotNull(format, "format");
            ContractUtils.RequiresNotNull(args, "args");
            ContractUtils.RequiresNotNull(kwArgs, "kwArgs");

            return Formatter.FormatString(context, format, args, kwArgs);
        }
开发者ID:joshholmes,项目名称:ironruby,代码行数:11,代码来源:NewStringFormatter.cs

示例5: PerformModuleReload

 public static void PerformModuleReload(PythonContext context, IAttributesCollection dict) {
     PythonModule scope = Importer.ImportModule(context.SharedContext, context.SharedContext.GlobalDict, "itertools", false, -1) as PythonModule;
     if (scope != null) {
         dict[SymbolTable.StringToId("map")] = scope.__dict__["imap"];
         dict[SymbolTable.StringToId("filter")] = scope.__dict__["ifilter"];
         dict[SymbolTable.StringToId("zip")] = scope.__dict__["izip"];
     }
 }
开发者ID:techarch,项目名称:ironruby,代码行数:8,代码来源:FutureBuiltins.cs

示例6: PerformModuleReload

 public static void PerformModuleReload(PythonContext context, IAttributesCollection dict) {
     Scope scope = Importer.ImportModule(context.SharedContext, context.SharedContext.GlobalScope.Dict, "itertools", false, -1) as Scope;
     if (scope != null) {
         dict[SymbolTable.StringToId("map")] = scope.LookupName(context, SymbolTable.StringToId("imap"));
         dict[SymbolTable.StringToId("filter")] = scope.LookupName(context, SymbolTable.StringToId("ifilter"));
         dict[SymbolTable.StringToId("zip")] = scope.LookupName(context, SymbolTable.StringToId("izip"));
     }
 }
开发者ID:xerxesb,项目名称:ironruby,代码行数:8,代码来源:FutureBuiltins.cs

示例7: Invoke

        public object Invoke(IAttributesCollection args) {
            Dictionary<object, object> dict = new Dictionary<object, object>();

            foreach (KeyValuePair<object, object> pair in args) {
                dict.Add(pair.Key, pair.Value);
            }

            return Invoke(dict);
        }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:9,代码来源:RestProvider.cs

示例8: PerformModuleReload

 public static void PerformModuleReload(PythonContext/*!*/ context, IAttributesCollection/*!*/ dict) {
     context.EnsureModuleException("PickleError", dict, "PickleError", "cPickle");
     context.EnsureModuleException("PicklingError", dict, "PicklingError", "cPickle");
     context.EnsureModuleException("UnpicklingError", dict, "UnpicklingError", "cPickle");
     context.EnsureModuleException("UnpickleableError", dict, "UnpickleableError", "cPickle");
     context.EnsureModuleException("BadPickleGet", dict, "BadPickleGet", "cPickle");
     dict[Symbols.Builtins] = context.BuiltinModuleInstance;
     dict[SymbolTable.StringToId("compatible_formats")] = PythonOps.MakeList("1.0", "1.1", "1.2", "1.3", "2.0");
 }
开发者ID:techarch,项目名称:ironruby,代码行数:9,代码来源:cPickle.cs

示例9: PointerType

            public PointerType(CodeContext/*!*/ context, string name, PythonTuple bases, IAttributesCollection members)
                : base(context, name, bases, members) {

                object type;
                if (members.TryGetValue(SymbolTable.StringToId("_type_"), out type) && !(type is INativeType)) {
                    throw PythonOps.TypeError("_type_ must be a type");
                }
                _type = (INativeType)type;
            }
开发者ID:joshholmes,项目名称:ironruby,代码行数:9,代码来源:PointerType.cs

示例10: partial

            /// <summary>
            /// Creates a new partial object with the provided positional and keyword arguments.
            /// </summary>
            public partial(CodeContext/*!*/ context, object func, [ParamDictionary]IAttributesCollection keywords, [NotNull]params object[]/*!*/ args) {
                if (!PythonOps.IsCallable(context, func)) {
                    throw PythonOps.TypeError("the first argument must be callable");
                }

                _function = func;
                _keywordArgs = keywords;
                _args = args;
                _context = context;
            }
开发者ID:joshholmes,项目名称:ironruby,代码行数:13,代码来源:_functools.cs

示例11: ArrayType

            public ArrayType(CodeContext/*!*/ context, string name, PythonTuple bases, IAttributesCollection dict)
                : base(context, name, bases, dict) {
                object len;
                int iLen;
                if (!dict.TryGetValue(SymbolTable.StringToId("_length_"), out len) || !(len is int) || (iLen = (int)len) < 0) {
                    throw PythonOps.AttributeError("arrays must have _length_ attribute and it must be a positive integer");
                }

                object type;
                if (!dict.TryGetValue(SymbolTable.StringToId("_type_"), out type)) {
                    throw PythonOps.AttributeError("class must define a '_type_' attribute");
                }

                _length = iLen;
                _type = (INativeType)type;

                if (_type is SimpleType) {
                    SimpleType st = (SimpleType)_type;
                    if (st._type == SimpleTypeKind.Char) {
                        // TODO: (c_int * 2).value isn't working
                        SetCustomMember(context,
                            SymbolTable.StringToId("value"),
                            new ReflectedExtensionProperty(
                                new ExtensionPropertyInfo(this, typeof(CTypes).GetMethod("GetCharArrayValue")),
                                NameType.Property | NameType.Python
                            )
                        );

                        SetCustomMember(context,
                            SymbolTable.StringToId("raw"),
                            new ReflectedExtensionProperty(
                                new ExtensionPropertyInfo(this, typeof(CTypes).GetMethod("GetWCharArrayRaw")),
                                NameType.Property | NameType.Python
                            )
                        );
                    } else if (st._type == SimpleTypeKind.WChar) {
                        SetCustomMember(context,
                            SymbolTable.StringToId("value"),
                            new ReflectedExtensionProperty(
                                new ExtensionPropertyInfo(this, typeof(CTypes).GetMethod("GetWCharArrayValue")),
                                NameType.Property | NameType.Python
                            )
                        );

                        SetCustomMember(context,
                            SymbolTable.StringToId("raw"),
                            new ReflectedExtensionProperty(
                                new ExtensionPropertyInfo(this, typeof(CTypes).GetMethod("GetWCharArrayRaw")),
                                NameType.Property | NameType.Python
                            )
                        );
                    }
                }
            }
开发者ID:techarch,项目名称:ironruby,代码行数:54,代码来源:ArrayType.cs

示例12: PerformModuleReload

 public static void PerformModuleReload(PythonContext/*!*/ context, IAttributesCollection/*!*/ dict) {
     dict.Add(SymbolTable.StringToId(_keyDefaultAction), "default");
     dict.Add(SymbolTable.StringToId(_keyOnceRegistry), new PythonDictionary());
     dict.Add(SymbolTable.StringToId(_keyFilters), new List() {
         // Default filters
         PythonTuple.MakeTuple("ignore", null, PythonExceptions.PendingDeprecationWarning, null, 0),
         PythonTuple.MakeTuple("ignore", null, PythonExceptions.ImportWarning, null, 0),
         PythonTuple.MakeTuple("ignore", null, PythonExceptions.BytesWarning, null, 0)
     });
     context.SetModuleState(_keyFields, dict);
 }
开发者ID:jcteague,项目名称:ironruby,代码行数:11,代码来源:_warnings.cs

示例13: AttributesDictionaryStorage

        public AttributesDictionaryStorage(IAttributesCollection data) {
            Debug.Assert(data != null);

            _hidden = new CommonDictionaryStorage();
            foreach (var key in data.Keys) {
                string strKey = key as string;
                if (strKey != null && strKey.Length > 0 && strKey[0] == '$') {
                    _hidden.Add(strKey, null);
                }
            }

            _data = data;
        }
开发者ID:rudimk,项目名称:dlr-dotnet,代码行数:13,代码来源:AttributesDictionaryStorage.cs

示例14: PerformModuleReload

        public static void PerformModuleReload(PythonContext/*!*/ context, IAttributesCollection/*!*/ dict) {
            if (!context.HasModuleState(_defaultTimeoutKey)) {
                context.SetModuleState(_defaultTimeoutKey, null);
            }

            context.SetModuleState(_defaultBufsizeKey, DefaultBufferSize);

            context.EnsureModuleException("sslerror", dict, "sslerror", "socket");
            PythonType socketErr = context.EnsureModuleException("socketerror", dict, "error", "socket");
            context.EnsureModuleException("socketherror", socketErr, dict, "herror", "socket");
            context.EnsureModuleException("socketgaierror", socketErr, dict, "gaierror", "socket");
            context.EnsureModuleException("sockettimeout", socketErr, dict, "timeout", "socket");
        }
开发者ID:jcteague,项目名称:ironruby,代码行数:13,代码来源:socket.cs

示例15: VerifyMaxLen

            private static int VerifyMaxLen(IAttributesCollection dict) {
                if (dict.Count != 1) {
                    throw PythonOps.TypeError("deque() takes at most 1 keyword argument ({0} given)", dict.Count);
                }
                
                object value;
                if (!dict.TryGetValue(SymbolTable.StringToId("maxlen"), out value)) {
                    IEnumerator<object> e = dict.Keys.GetEnumerator();
                    if (e.MoveNext()) {
                        throw PythonOps.TypeError("deque(): '{0}' is an invalid keyword argument", e.Current);
                    }
                }

                if (value is int) return (int)value;
                else if (value is Extensible<int>) return ((Extensible<int>)value).Value;
                throw PythonOps.TypeError("deque(): keyword argument 'maxlen' requires integer");
            }
开发者ID:octavioh,项目名称:ironruby,代码行数:17,代码来源:collections.cs


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