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


C# SymbolId.ToString方法代码示例

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


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

示例1: TryGetExtraValue

        protected override bool TryGetExtraValue(SymbolId key, out object value)
        {
            var property = _viewType.GetProperty(key.ToString());
            if (property != null)
            {
                value = property.GetValue(_view, null);
                return true;
            }

            var field = _viewType.GetField(key.ToString());
            if (field != null)
            {
                value = field.GetValue(_view);
                return true;
            }

            var method = _viewType.GetMethod(key.ToString());
            if (method != null)
            {
                var parameterTypes = method.GetParameters().Select(p => p.ParameterType).ToList();
                parameterTypes.Add(method.ReturnType);
                value = Delegate.CreateDelegate(
                    CompilerHelpers.MakeCallSiteDelegateType(parameterTypes.ToArray()),
                    _view,
                    key.ToString());
                return true;
            }

            if (_view.TryGetViewData(key.ToString(), out value))
                return true;

            value = null;
            return false;
        }
开发者ID:ronniebarker,项目名称:spark,代码行数:34,代码来源:ScriptingViewSymbolDictionary.cs

示例2: SetPropertyHelper

 public static void SetPropertyHelper(object prop, object instance, object newValue, SymbolId name) {
     PythonTypeSlot desc = prop as PythonTypeSlot;
     if (desc == null) {
         throw PythonOps.TypeError("Expected settable property for {0}, but found {1}",
             name.ToString(), DynamicHelpers.GetPythonType(prop).Name);
     }
     desc.TrySetValue(DefaultContext.Default, instance, DynamicHelpers.GetPythonType(instance), newValue);
 }
开发者ID:octavioh,项目名称:ironruby,代码行数:8,代码来源:UserTypeOps.cs

示例3: GetPropertyHelper

 public static object GetPropertyHelper(object prop, object instance, SymbolId name) {
     PythonTypeSlot desc = prop as PythonTypeSlot;
     if (desc == null) {
         throw PythonOps.TypeError("Expected property for {0}, but found {1}",
             name.ToString(), DynamicHelpers.GetPythonType(prop).Name);
     }
     object value;
     desc.TryGetValue(DefaultContext.Default, instance, DynamicHelpers.GetPythonType(instance), out value);
     return value;
 }
开发者ID:octavioh,项目名称:ironruby,代码行数:10,代码来源:UserTypeOps.cs

示例4: if

    bool IAttributesInjector.TryGetAttr(object obj, SymbolId nameSymbol, out object value) {
        string name = nameSymbol.ToString();
        XmlElement xml = obj as XmlElement;

        if (xml != null) {
            XmlAttribute attr = xml.Attributes[name];
            if (attr != null) {
                value = attr.Value;
                return true;
            }

            for (XmlNode n = xml.FirstChild; n != null; n = n.NextSibling) {
                if (n is XmlElement && string.CompareOrdinal(n.Name, name) == 0) {
                    if (n.HasChildNodes && n.FirstChild == n.LastChild &&
                        n.FirstChild is XmlText) {
                        value = n.InnerText;
                    }
                    else {
                        value = n;
                    }

                    return true;
                }
            }

            // see if they ask for pluralized element - return array in that case
            string singularName = null;
            List<XmlNode> elementList = null;

            for (XmlNode n = xml.FirstChild; n != null; n = n.NextSibling) {
                if (n is XmlElement) {
                    if (singularName == null) {
                        if (DynamicWebServiceHelpers.Pluralizer.IsNounPluralOfNoun(name, n.Name)) {
                            singularName = n.Name;
                            elementList = new List<XmlNode>();
                            elementList.Add(n);
                        }
                    }
                    else if (string.CompareOrdinal(n.Name, singularName) == 0) {
                        elementList.Add(n);
                    }
                }
            }

            if (elementList != null) {
                value = elementList.ToArray();
                return true;
            }
        }

        value = null;
        return false;
    }
开发者ID:nuxleus,项目名称:Nuxleus.Extf,代码行数:53,代码来源:XmlElementAttributesInjector.cs

示例5: AddRemoveEventHelper

        public static void AddRemoveEventHelper(object method, object instance, PythonType dt, object eventValue, SymbolId name) {
            object callable = method;

            // TODO: dt gives us a PythonContext which we should use

            PythonTypeSlot dts = method as PythonTypeSlot;
            if (dts != null) {
                if (!dts.TryGetValue(DefaultContext.Default, instance, dt, out callable))
                    throw PythonOps.AttributeErrorForMissingAttribute(dt.Name, name);
            }

            if (!PythonOps.IsCallable(DefaultContext.Default, callable)) {
                throw PythonOps.TypeError("Expected callable value for {0}, but found {1}", name.ToString(),
                    PythonTypeOps.GetName(method));
            }

            PythonCalls.Call(callable, eventValue);
        }
开发者ID:octavioh,项目名称:ironruby,代码行数:18,代码来源:UserTypeOps.cs

示例6: TrySetExtraValue

        protected override bool TrySetExtraValue(SymbolId key, object value)
        {
            var property = _viewType.GetProperty(key.ToString());
            if (property != null)
            {
                property.SetValue(_view, value, null);
                return true;
            }

            var field = _viewType.GetField(key.ToString());
            if (field != null)
            {
                field.SetValue(_view, value);
                return true;
            }

            return false;
        }
开发者ID:ronniebarker,项目名称:spark,代码行数:18,代码来源:ScriptingViewSymbolDictionary.cs

示例7: DeleteCustomMember

        internal bool DeleteCustomMember(CodeContext context, SymbolId name) {
            if (name == Symbols.Class) throw PythonOps.TypeError("__class__ must be set to class");
            if (name == Symbols.Dict) throw PythonOps.TypeError("__dict__ must be set to a dictionary");

            object delFunc;
            if (_class.HasDelAttr && _class.TryLookupSlot(Symbols.DelAttr, out delFunc)) {
                PythonCalls.Call(context, _class.GetOldStyleDescriptor(context, delFunc, this, _class), name.ToString());
                return true;
            }


            if (name == Symbols.Unassign) {
                // removing finalizer
                if (HasFinalizer() && !_class.HasFinalizer) {
                    ClearFinalizer();
                }
            }

            if (!((IAttributesCollection)_dict).Remove(name)) {
                throw PythonOps.AttributeError("{0} is not a valid attribute", SymbolTable.IdToString(name));
            }
            return true;
        }
开发者ID:jcteague,项目名称:ironruby,代码行数:23,代码来源:OldInstance.cs

示例8: SetCustomMember

 internal void SetCustomMember(CodeContext context, SymbolId name, object value) {
     object setFunc;
     int nameId = name.Id;
     if (nameId == Symbols.Class.Id) {
         SetClass(value);
     } else if (nameId == Symbols.Dict.Id) {
         SetDict(context, value);
     } else if (_class.HasSetAttr && _class.TryLookupSlot(Symbols.SetAttr, out setFunc)) {
         PythonCalls.Call(context, _class.GetOldStyleDescriptor(context, setFunc, this, _class), name.ToString(), value);
     } else if (nameId == Symbols.Unassign.Id) {
         SetFinalizer(context, name, value);
     } else {
         ((IAttributesCollection)_dict)[name] = value;
     }
 }
开发者ID:jcteague,项目名称:ironruby,代码行数:15,代码来源:OldInstance.cs

示例9: TrySetExtraValue

 public override bool TrySetExtraValue(SymbolId key, object value)
 {
     if(value == Uninitialized.instance)
         throw Ops.TypeError("can't delete '{0}' from dictproxy", key.ToString());
     throw Ops.TypeError("can't set '{0}' in dictproxy",key.ToString());
 }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:6,代码来源:ReflectedType.cs

示例10: DeleteCustomMember

        internal bool DeleteCustomMember(CodeContext/*!*/ context, SymbolId name) {
            Debug.Assert(context != null);

            PythonTypeSlot dts;
            if (TryResolveSlot(context, name, out dts)) {
                if (dts.TryDeleteValue(context, null, this))
                    return true;
            }

            if (IsSystemType) {
                throw new MissingMemberException(String.Format("can't delete attributes of built-in/extension type '{0}'", Name, SymbolTable.IdToString(name)));
            }

            if (!_dict.Remove(name)) {
                throw new MissingMemberException(String.Format(CultureInfo.CurrentCulture,
                    IronPython.Resources.MemberDoesNotExist,
                    name.ToString()));
            }

            UpdateVersion();
            return true;
        }
开发者ID:octavioh,项目名称:ironruby,代码行数:22,代码来源:PythonType.cs

示例11: InvokeSpecialMethod

        public object InvokeSpecialMethod(object target, SymbolId name, params object[] args)
        {
            object ret;
            if (TryInvokeSpecialMethod(target, name, out ret, args)) return ret;

            throw Ops.TypeError("{0} object has no attribute '{1}'",
                Ops.StringRepr(Ops.GetDynamicType(target)),
                name.ToString());
        }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:9,代码来源:DynamicType.cs

示例12: SetAttr

        public void SetAttr(ICallerContext context, SymbolId name, object value)
        {
            object setFunc;

            if (name.Id == SymbolTable.ClassId) {
                OldClass oc = value as OldClass;
                if (oc == null) {
                    throw Ops.TypeError("__class__ must be set to class");
                }
                __class__ = oc;
            } else if (name.Id == SymbolTable.DictId) {
                IAttributesDictionary dict = value as IAttributesDictionary;
                if (dict == null) {
                    throw Ops.TypeError("__dict__ must be set to a dictionary");
                }
                if (HasFinalizer() && !__class__.HasFinalizer) {
                    if (!dict.ContainsKey(SymbolTable.Unassign)) {
                        ClearFinalizer();
                    }
                } else if (dict.ContainsKey(SymbolTable.Unassign)) {
                    AddFinalizer();
                }

                __dict__ = dict;
            } else if (__class__.HasSetAttr && __class__.TryLookupSlot(SymbolTable.SetAttr, out setFunc)) {
                Ops.Call(Ops.GetDescriptor(setFunc, this, __class__), name.ToString(), value);
            } else if (name.Id == SymbolTable.UnassignId) {
                if (!HasFinalizer()) {
                    // user is defining __del__ late bound for the 1st time
                    AddFinalizer();
                }

                __dict__[name] = value;
            } else {
                __dict__[name] = value;
            }
        }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:37,代码来源:OldClass.cs

示例13: TryGetLocal

        private bool TryGetLocal(SymbolId symbol, out object ret)
        {
            if (f_locals != null) {
                // couple of exception-free fast paths...
                IAttributesDictionary ad = f_locals as IAttributesDictionary;
                if (ad != null) {
                    return ad.TryGetValue(symbol, out ret);
                }

                string name = symbol.ToString();

                // always check for IMapping first, it does the right thing
                // w.r.t. overriding __getitem__ & TryGetValue.
                IMapping imap = f_locals as IMapping;
                if (imap != null) {
                    return imap.TryGetValue(name, out ret);
                }

                IDictionary<object, object> dict = f_locals as IDictionary<object, object>;
                if (dict != null) {
                    return dict.TryGetValue(name, out ret);
                }

                // uh-oh, we may end up throwing...
                try {
                    ret = Ops.GetIndex(f_locals, name);
                    return true;
                } catch (KeyNotFoundException) {
                    // return false
                }
            }
            ret = null;
            return false;
        }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:34,代码来源:ModuleScope.cs

示例14: DelLocal

 public void DelLocal(SymbolId symbol)
 {
     try {
         Ops.DelIndex(f_locals, symbol.ToString());
     } catch (KeyNotFoundException) {
         throw Ops.NameError("name {0} is not defined", symbol);
     }
 }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:8,代码来源:ModuleScope.cs

示例15: DeleteAttr

        public void DeleteAttr(ICallerContext context, SymbolId name)
        {
            if (name == SymbolTable.Dict)
                throw Ops.TypeError(name.ToString() + " may not be deleted");

            if (dict == null || !dict.ContainsKey(name)) {
                // We check for SymbolTable.Module as the user code can modify it
                if (name == SymbolTable.Module)
                    throw Ops.TypeError(name.ToString() + " may not be deleted");

                throw Ops.AttributeError("no attribute {0}", name);
            }

            dict.Remove(name);
        }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:15,代码来源:Function.cs


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