本文整理汇总了C#中IAttributesCollection类的典型用法代码示例。如果您正苦于以下问题:C# IAttributesCollection类的具体用法?C# IAttributesCollection怎么用?C# IAttributesCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IAttributesCollection类属于命名空间,在下文中一共展示了IAttributesCollection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: __new__
public static object __new__(CodeContext/*!*/ context, [NotNull]PythonType cls, string name, PythonTuple bases, IAttributesCollection dict) {
if (cls != TypeCache.OldClass) throw PythonOps.TypeError("{0} is not a subtype of classobj", cls.Name);
if (!dict.ContainsKey(Symbols.Module)) {
object moduleValue;
if (context.GlobalScope.TryGetVariable(Symbols.Name, out moduleValue)) {
dict[Symbols.Module] = moduleValue;
}
}
foreach (object o in bases) {
if (o is PythonType) {
return PythonOps.MakeClass(context, name, bases._data, String.Empty, dict);
}
}
return new OldClass(name, bases, dict, String.Empty);
}
开发者ID:joshholmes,项目名称:ironruby,代码行数:18,代码来源:OldClass.cs
示例17: EvalProbabilityForCategoryType
private double EvalProbabilityForCategoryType(string categoryType, IAttributesCollection attributes)
{
double result = 1.0;
foreach (string attribute in attributes.Keys)
{
double probability = this._category.Engine.GetCategoryType(categoryType).GetProbability(attribute);
if (probability == 0.0)
{
result *= 0.00001;
}
else
{
result *= probability;
}
}
return result;
}
开发者ID:spolnik,项目名称:NaiveBayesProject,代码行数:19,代码来源:Classifer.cs
示例18: PerformModuleReload
public static void PerformModuleReload(PythonContext/*!*/ context, IAttributesCollection/*!*/ dict) {
context.EnsureModuleException("ArgumentError", dict, "ArgumentError", "_ctypes");
context.EnsureModuleException("COMError", dict, "COMError", "_ctypes");
// TODO: Provide an implementation which is coordinated with our _refCountTable
context.SystemState.__dict__["getrefcount"] = null;
PythonDictionary pointerTypeCache = new PythonDictionary();
dict[SymbolTable.StringToId("_pointer_type_cache")] = pointerTypeCache;
context.SetModuleState(_pointerTypeCacheKey, pointerTypeCache);
if (Environment.OSVersion.Platform == PlatformID.Win32NT ||
Environment.OSVersion.Platform == PlatformID.Win32S ||
Environment.OSVersion.Platform == PlatformID.Win32Windows ||
Environment.OSVersion.Platform == PlatformID.WinCE) {
context.SetModuleState(_conversion_mode, PythonTuple.MakeTuple("mbcs", "ignore"));
} else {
context.SetModuleState(_conversion_mode, PythonTuple.MakeTuple("ascii", "strict"));
}
}
开发者ID:techarch,项目名称:ironruby,代码行数:20,代码来源:_ctypes.cs
示例19: SimpleType
public SimpleType(CodeContext/*!*/ context, string name, PythonTuple bases, IAttributesCollection dict)
: base(context, name, bases, dict) {
object val;
string sVal;
const string allowedTypes = "?cbBghHiIlLdfuzZqQPXOv";
if (!TryGetBoundCustomMember(context, SymbolTable.StringToId("_type_"), out val) ||
(sVal = StringOps.AsString(val)) == null ||
sVal.Length != 1 ||
allowedTypes.IndexOf(sVal[0]) == -1) {
throw PythonOps.AttributeError("AttributeError: class must define a '_type_' attribute which must be a single character string containing one of '{0}'.", allowedTypes);
}
_charType = sVal[0];
switch (sVal[0]) {
case '?': _type = SimpleTypeKind.Boolean; break;
case 'c': _type = SimpleTypeKind.Char; break;
case 'b': _type = SimpleTypeKind.SignedByte; break;
case 'B': _type = SimpleTypeKind.UnsignedByte; break;
case 'h': _type = SimpleTypeKind.SignedShort; break;
case 'H': _type = SimpleTypeKind.UnsignedShort; break;
case 'i': _type = SimpleTypeKind.SignedInt; break;
case 'I': _type = SimpleTypeKind.UnsignedInt; break;
case 'l': _type = SimpleTypeKind.SignedLong; break;
case 'L': _type = SimpleTypeKind.UnsignedLong; break;
case 'f': _type = SimpleTypeKind.Single; break;
case 'g': // long double, new in 2.6
case 'd': _type = SimpleTypeKind.Double; break;
case 'q': _type = SimpleTypeKind.SignedLongLong; break;
case 'Q': _type = SimpleTypeKind.UnsignedLongLong; break;
case 'O': _type = SimpleTypeKind.Object; break;
case 'P': _type = SimpleTypeKind.Pointer; break;
case 'z': _type = SimpleTypeKind.CharPointer; break;
case 'Z': _type = SimpleTypeKind.WCharPointer; break;
case 'u': _type = SimpleTypeKind.WChar; break;
case 'p': // what are these?
case 'X':
case 'v':
throw new NotImplementedException("simple type " + sVal);
}
}
开发者ID:m4dc4p,项目名称:ironruby,代码行数:41,代码来源:SimpleType.cs
示例20: CompileWithStaticGlobals
private void CompileWithStaticGlobals(out DlrMainCallTarget target, out IAttributesCollection globals) {
// Create typegen
TypeGen typeGen = Snippets.Shared.DefineType(MakeDebugName(), typeof(CustomSymbolDictionary), false, SourceUnit.EmitDebugSymbols);
typeGen.TypeBuilder.DefineDefaultConstructor(MethodAttributes.Public);
// Create rewriter
GlobalStaticFieldRewriter rewriter = new GlobalStaticFieldRewriter(typeGen);
// Compile lambda
LambdaExpression lambda = rewriter.RewriteLambda(Code, "Initialize");
MethodBuilder mb = typeGen.TypeBuilder.DefineMethod(lambda.Name, CompilerHelpers.PublicStatic);
lambda.CompileToMethod(mb, SourceUnit.EmitDebugSymbols);
// Create globals dictionary, finish type
rewriter.EmitDictionary();
Type type = typeGen.FinishType();
globals = (IAttributesCollection)Activator.CreateInstance(type);
// Create target
target = (DlrMainCallTarget)Delegate.CreateDelegate(typeof(DlrMainCallTarget), type.GetMethod("Initialize"));
// TODO: clean this up after clarifying dynamic site initialization logic
InitializeFields(type);
}
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:24,代码来源:OptimizedScriptCode.cs
注:本文中的IAttributesCollection类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论