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


C# Reference.ToString方法代码示例

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


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

示例1: ReferenceListItem

        // TODO: Find a *much* nicer way of dealing with this. :X
        public ReferenceListItem(Reference reference, Display display, Resource context)
        {
            this.Reference = reference;

            string displayStr;

            switch (display)
            {
                case Display.NoMod:
                    displayStr = reference.ToString(false, context);
                    break;
                case Display.WithMod:
                    displayStr = reference.ToString(true, context);
                    break;
                case Display.SourcedNoMod:
                    displayStr = reference.ToStringSourced(false, context);
                    break;
                case Display.SourcedIncoming:
                    displayStr = "[INCOMING] " + reference.ToStringSourced(false, context);
                    break;
                default:
                    throw new ArgumentException("display");
            }

            this.AddText(displayStr);

            SetBackground(reference.Valid ? ItemStatus.Okay : ItemStatus.Error);

            this.CommandBindings.Add(new System.Windows.Input.CommandBinding(
                System.Windows.Input.ApplicationCommands.Copy,
                (o, e) => System.Windows.Clipboard.SetText(string.Concat(reference.Origin.Location, " : ", reference.Target.Location))
                ));

            this.ContextMenu = new ContextMenu();

            var items = this.ContextMenu.Items;

            items.Add(new MenuItem { Header = "_Copy...", Command = System.Windows.Input.ApplicationCommands.Copy, CommandTarget = this });

            items.Add(CreateItem(Reference.Definition, "_Definition: "));
            // Add the origin unless it's the same
            if (Reference.Definition != reference.Origin)
                items.Add(CreateItem(Reference.Origin, "_Origin: "));
            // Add the definition *unless* it's either.
            if (Reference.Definition != Reference.Target && Reference.Origin != Reference.Target)
                items.Add(CreateItem(Reference.Target, "_Target: "));
        }
开发者ID:Quit,项目名称:Jofferson,代码行数:48,代码来源:ReferenceListItem.cs

示例2: execute

        internal object execute(Node n, ExecutionContext x)
        {
            int i, j;
            List<Node> aNode;
            ExecutionContext sEcon;
            JSObjectBase jaa;
            JSObjectBase f, tVal;
            object r, s, u = null, v = null;
            Node tNode = null, rNode = null, uNode = null;
            bool matchDefault = false;
            bool switchLoop;

            if (TraceExec)
                System.Console.Write("Execute[" + n.ToString() + " => ");

            try
            {
                switch (n.type)
                {
                    case TokenType.Function:
                        if (n.functionForm != StatementForm.DECLARED_FORM)
                        {
                            if (n.name == null || n.name == "" || n.functionForm == StatementForm.STATEMENT_FORM)
                            {
                                v = new FunctionObject(GLOBAL, n, x.scope);
                                if (n.functionForm == StatementForm.STATEMENT_FORM)
                                    x.scope.jobject.SetItem(GLOBAL, n.name, new JSSimpleProperty(n.name, v));
                            }
                            else
                            {
                                tVal = new JSObject();
                                ExecutionContext tmp = x.scope;
                                x.scope = new ExecutionContext();
                                x.scope.jobject = tVal;
                                x.scope.parent = tmp;
                                try
                                {
                                    v = new FunctionObject(GLOBAL, n, x.scope);
                                    tVal.SetItem(GLOBAL, n.name, new JSSimpleProperty(n.name, v, true, true));
                                }
                                finally
                                {
                                    x.scope = x.scope.parent;
                                }
                            }
                        }
                        break;

                    case TokenType.SCRIPT:
                        tVal = x.scope.jobject;
                        aNode = n.funDecls;
                        for (i = 0, j = aNode.Count; i < j; i++)
                        {
                            s = aNode[i].name;
                            f = new FunctionObject(GLOBAL, aNode[i], x.scope);
                            tVal.SetItem(GLOBAL, s.ToString(), new JSSimpleProperty(s.ToString(), f, x.type != CodeType.EVAL_CODE));
                        }
                        aNode = n.varDecls;
                        for (i = 0, j = aNode.Count; i < j; i++)
                        {
                            uNode = aNode[i];
                            s = uNode.name;
                            if (uNode.readOnly && tVal.HasOwnProperty(s.ToString()))
                            {
                                throw new TypeError
                                    ("Redeclaration of const " + s, uNode.filename, uNode.lineno);
                            }
                            if (uNode.readOnly || !tVal.HasOwnProperty(s.ToString()))
                            {
                                tVal.SetItem(GLOBAL, s.ToString(), new JSSimpleProperty(s.ToString(), JSUndefined.Undefined, x.type != CodeType.EVAL_CODE, uNode.readOnly));
                            }
                        }
                        // FALL THROUGH
                        for (i = 0, j = n.Count; i < j; i++)
                            execute(n[i], x);
                        break;

                    case TokenType.BLOCK:
                        for (i = 0, j = n.Count; i < j; i++)
                            execute(n[i], x);
                        break;

                    case TokenType.If:
                        if (JSObject.ToBool(GLOBAL, execute(n.condition, x)))
                            execute(n.thenPart, x);
                        else if (n.elsePart != null)
                            execute(n.elsePart, x);
                        break;

                    case TokenType.Switch:
                        s = execute(n.discriminant, x);
                        aNode = n.cases;
                        Node tt;
                        switchLoop = false;
                        for (i = 0, j = aNode.Count; ; i++)
                        {
                            if (i == j)
                            {
                                if (n.defaultIndex >= 0)
                                {
//.........这里部分代码省略.........
开发者ID:prozacchiwawa,项目名称:pygmalion,代码行数:101,代码来源:jsexec.cs


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