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


C# IScriptable.Put方法代码示例

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


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

示例1: ImportType

        public static void ImportType(IScriptable scope, Type type)
        {
            if (!type.IsPublic)
                return;

            if (ScriptRuntime.IsNativeRuntimeType (type))
                return;

            // Cannot define 'Object'
            if (type.Name == "Object")
                return;

            string [] ns = type.FullName.Split ('.');

            IScriptable parent = scope;
            for (int i = 0; i < ns.Length - 1; i++) {
                IScriptable obj = (parent.Get (ns [i], parent) as IScriptable);
                if (obj == null) {
                    obj = new BuiltinObject ();
                    parent.Put (ns [i], parent, obj);
                }
                parent = obj;
            }

            object thisObj = null;
            if (type.IsEnum) {
                thisObj = new CliEnum ((Enum)Activator.CreateInstance (type));
            }
            else {
                thisObj = CliType.GetNativeCliType (type);

            }
            // Define as toplevel object
            scope.Put (ns [ns.Length - 1], scope, thisObj);

            // Define as full qualified name
            parent.Put (ns [ns.Length - 1], parent, thisObj);
        }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:38,代码来源:CliPackage.cs

示例2: DefineProperty

 /// <summary> Utility method to add properties to arbitrary Scriptable object.
 /// If destination is instance of ScriptableObject, calls
 /// defineProperty there, otherwise calls put in destination
 /// ignoring attributes
 /// </summary>
 public static void DefineProperty (IScriptable destination, string propertyName, object value, int attributes)
 {
     if (!(destination is ScriptableObject)) {
         destination.Put (propertyName, destination, value);
         return;
     }
     ScriptableObject so = (ScriptableObject)destination;
     so.DefineProperty (propertyName, value, attributes);
 }
开发者ID:rumincayman,项目名称:EcmaScript.NET,代码行数:14,代码来源:ScriptableObject.cs

示例3: Put

 /// <summary> Sets the value of the indexed property, creating it if need be.
 /// 
 /// </summary>
 /// <param name="index">the numeric index for the property
 /// </param>
 /// <param name="start">the object whose property is being set
 /// </param>
 /// <param name="value">value to set the property to
 /// </param>
 public virtual object Put (int index, IScriptable start, object value)
 {
     Slot slot = GetSlot (null, index);
     if (slot == null) {
         if (start != this) {
             return start.Put (index, start, value);
         }
         slot = AddSlot (null, index, null);
     }
     if (start == this && Sealed) {
         throw Context.ReportRuntimeErrorById ("msg.modify.sealed", Convert.ToString (index));
     }
     if ((slot.attributes & ScriptableObject.READONLY) != 0) {
         return slot.GetValue (null, start, start); // TODO: ???
     }
     if (this == start) {
         return slot.SetValue (null, start, start, value);
     }
     else {
         return start.Put (index, start, value);
     }
 }
开发者ID:rumincayman,项目名称:EcmaScript.NET,代码行数:31,代码来源:ScriptableObject.cs

示例4: Put

 public override object Put (string name, IScriptable start, object value)
 {
     int info = FindInstanceIdInfo (name);
     if (info != 0) {
         if (start == this && Sealed) {
             throw Context.ReportRuntimeErrorById ("msg.modify.sealed", name);
         }
         int attr = (int)((uint)info >> 16);
         if ((attr & READONLY) == 0) {
             if (start == this) {
                 int id = (info & 0xFFFF);
                 SetInstanceIdValue (id, value);
             }
             else {
                 return start.Put (name, start, value);
             }
         } else {
             ReadOnlyPropertyChanged (name);
         }
         return value;
     }
     if (prototypeValues != null) {
         int id = prototypeValues.FindId (name);
         if (id != 0) {
             if (start == this && Sealed) {
                 throw Context.ReportRuntimeErrorById ("msg.modify.sealed", name);
             }
             prototypeValues.Set (id, start, value);
             return value;
         }
     }
     return base.Put (name, start, value);
 }
开发者ID:hazzik,项目名称:EcmaScript.NET,代码行数:33,代码来源:IdScriptableObject.cs

示例5: Set

 internal void Set (int id, IScriptable start, object value)
 {
     if (value == UniqueTag.NotFound)
         throw new ArgumentException ();
     EnsureId (id);
     int attr = attributeArray [id - 1];
     if ((attr & ScriptableObject.READONLY) == 0) {
         if (start == obj) {
             if (value == null) {
                 value = UniqueTag.NullValue;
             }
             int valueSlot = (id - 1) * SLOT_SPAN + VALUE_SLOT;
             lock (this) {
                 valueArray [valueSlot] = value;
             }
         }
         else {
             int nameSlot = (id - 1) * SLOT_SPAN + NAME_SLOT;
             string name = (string)valueArray [nameSlot];
             start.Put (name, start, value);
         }
     }
 }
开发者ID:hazzik,项目名称:EcmaScript.NET,代码行数:23,代码来源:IdScriptableObject.cs

示例6: Put

 /// <summary> Sets the value of the named property, creating it if need be.
 /// 
 /// If the property was created using defineProperty, the
 /// appropriate setter method is called. <p>
 /// 
 /// If the property's attributes include READONLY, no action is
 /// taken.
 /// This method will actually set the property in the start
 /// object.
 /// 
 /// </summary>
 /// <param name="name">the name of the property
 /// </param>
 /// <param name="start">the object whose property is being set
 /// </param>
 /// <param name="value">value to set the property to
 /// </param>
 public virtual object Put (string name, IScriptable start, object value)
 {
     Slot slot = lastAccess; // Get local copy
     if ((object)name != (object)slot.stringKey || slot.wasDeleted != 0) {
         int hash = name.GetHashCode ();
         slot = GetSlot (name, hash);
         if (slot == null) {
             if (start != this) {
                 start.Put (name, start, value);
                 return value;
             }
             slot = AddSlot (name, hash, null);
         }
         // Note: cache is not updated in put
     }
     if (start == this && Sealed) {
         throw Context.ReportRuntimeErrorById ("msg.modify.sealed", name);
     }
     if ((slot.attributes & ScriptableObject.READONLY) != 0) {
         ReadOnlyPropertyChanged (name);
         return value;
     }
     if (this == start) {
         return slot.SetValue (null, start, start, value);
     }
     else {
         if (slot.setter != null) {
             Slot newSlot = (Slot)slot.Clone ();
             ((ScriptableObject)start).AddSlotImpl (newSlot.stringKey, newSlot.intKey, newSlot);
             return newSlot.SetValue (null, start, start, value);
         }
         else {
             return start.Put (name, start, value);
         }
     }
     return value;
 }
开发者ID:hazzik,项目名称:EcmaScript.NET,代码行数:54,代码来源:ScriptableObject.cs

示例7: doScriptableIncrDecr

 private static object doScriptableIncrDecr(IScriptable target, string id, IScriptable protoChainStart, object value, int incrDecrMask)
 {
     bool post = ((incrDecrMask & Node.POST_FLAG) != 0);
     double number;
     if (CliHelper.IsNumber (value)) {
         number = Convert.ToDouble (value);
     }
     else {
         number = ScriptConvert.ToNumber (value);
         if (post) {
             // convert result to number
             value = number;
         }
     }
     if ((incrDecrMask & Node.DECR_FLAG) == 0) {
         ++number;
     }
     else {
         --number;
     }
     object result = number;
     target.Put (id, protoChainStart, result);
     if (post) {
         return value;
     }
     else {
         return result;
     }
 }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:29,代码来源:ScriptRuntime.cs

示例8: setName

 public static object setName(IScriptable bound, object value, Context cx, IScriptable scope, string id)
 {
     if (bound != null) {
         if (bound is XMLObject) {
             XMLObject xmlObject = (XMLObject)bound;
             xmlObject.EcmaPut (cx, id, value);
         }
         else {
             ScriptableObject.PutProperty (bound, id, value);
         }
     }
     else {
         // "newname = 7;", where 'newname' has not yet
         // been defined, creates a new property in the
         // top scope unless strict mode is specified.
         if (cx.HasFeature (Context.Features.StrictVars)) {
             throw Context.ReportRuntimeErrorById ("msg.assn.create.strict", id);
         }
         // Find the top scope by walking up the scope chain.
         bound = ScriptableObject.GetTopLevelScope (scope);
         if (cx.useDynamicScope) {
             bound = checkDynamicScope (cx.topCallScope, bound);
         }
         bound.Put (id, bound, value);
     }
     return value;
 }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:27,代码来源:ScriptRuntime.cs

示例9: initFunction

 public static void initFunction(Context cx, IScriptable scope, BuiltinFunction function, int type, bool fromEvalCode)
 {
     if (type == FunctionNode.FUNCTION_STATEMENT) {
         string name = function.FunctionName;
         if (name != null && name.Length != 0) {
             if (!fromEvalCode) {
                 // ECMA specifies that functions defined in global and
                 // function scope outside eval should have DONTDELETE set.
                 ScriptableObject.DefineProperty (scope, name, function, ScriptableObject.PERMANENT);
             }
             else {
                 scope.Put (name, scope, function);
             }
         }
     }
     else if (type == FunctionNode.FUNCTION_EXPRESSION_STATEMENT) {
         string name = function.FunctionName;
         if (name != null && name.Length != 0) {
             // Always put function expression statements into initial
             // activation object ignoring the with statement to follow
             // SpiderMonkey
             while (scope is BuiltinWith) {
                 scope = scope.ParentScope;
             }
             scope.Put (name, scope, function);
         }
     }
     else {
         throw Context.CodeBug ();
     }
 }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:31,代码来源:ScriptRuntime.cs


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