Ejemplo n.º 1
0
        internal ObjectMethod GetFileObjectMethods(Guid id)
        {
            ObjectMethod refObject = null;

            List <FileInfo> listFiles = GetListFilesObjectMethods();

            if (listFiles == null)
            {
                return(refObject);
            }

            Json json = new Json();

            FileInfo fileObject = new FileInfo(GetFileNameObjectMethod(id));

            if (!fileObject.Exists)
            {
                json.SerializeObjectMethod(fileObject, new ObjectMethod());
            }

            refObject      = json.DeserialiseObjectMethod(fileObject);
            refObject.ID   = id;
            refObject.Path = fileObject.FullName;

            return(refObject);
        }
Ejemplo n.º 2
0
Archivo: Fun.cs Proyecto: MechWipf/lrpc
        /// <summary>
        /// register the method being called
        /// </summary>
        /// <param name="name">the name to use when calling</param>
        /// <param name="obj">method object</param>
        /// <param name="fun">the actual method used</param>
        public void Regist(string name, object obj, MethodInfo fun)
        {
            ObjectMethod om = new ObjectMethod();

            om.obj = obj;
            om.fun = fun;
            funs.Add(name, om);
        }
        public ObjectMethod[] GetFolderMethods(string ticketId, decimal FolderId)
        {
            ArrayList    list   = new ArrayList();
            ObjectMethod method = new ObjectMethod();

            list.Add(method);
            return(list.ToArray(typeof(ObjectMethod)) as ObjectMethod[]);
        }
Ejemplo n.º 4
0
 public Armor(string name, Token token) : base(name, token)
 {
     // Instantiate Object Methods
     AddArmorEffect            = new ObjectMethod <int, string, string, string>(Method_AddArmorEffect);
     AddArmorEffectSpectacular = new ObjectMethod <int, string, string, string>(
         Method_AddArmorEffectSpectacular
         );
 }
Ejemplo n.º 5
0
        internal void SaveObjectMethods(Guid id, ObjectMethod objectMethod)
        {
            if (!CreatePathDataFiles())
            {
                return;
            }

            new Json().SerializeObjectMethod(new FileInfo(GetFileNameObjectMethod(id)), objectMethod);
        }
Ejemplo n.º 6
0
    public void TestAsyncCallWithObjects()
    {
        int          result;
        IAsyncResult ar;
        ObjectMethod m = new ObjectMethod(ObjectAdd);

        ar = m.BeginInvoke(10, 20, null, null);

        result = (int)m.EndInvoke(ar);

        AssertEquals("result==30", 30, result);
    }
Ejemplo n.º 7
0
 public void Initialize(ObjectMethod Method, bool StartFromPause = false)
 {
     _m = Method;
     if (StartFromPause)
     {
         State = UIInfoActualizerState.Paused;
     }
     else
     {
         State = UIInfoActualizerState.Active;
     }
 }
Ejemplo n.º 8
0
	public void TestAsyncCallWithObjects()
	{
		int result;
		IAsyncResult ar;
		ObjectMethod m = new ObjectMethod(ObjectAdd);
		
		ar = m.BeginInvoke(10, 20, null, null);
		
		result = (int)m.EndInvoke(ar);
		
		AssertEquals("result==30", 30, result);
	}
Ejemplo n.º 9
0
        public DocTopic ParseMethod(ObjectMethod method, DocTopic parentClassTopic)
        {
            var topic = new DocTopic(_project)
            {
                Title = parentClassTopic.ClassInfo.Classname + "." + method.Name,
                //ListTitle = method.Name,
                DisplayType = method.IsConstructor ? "classconstructor" : "classmethod",

                ClassInfo = new ClassInfo
                {
                    MemberName    = method.Name,
                    Signature     = method.Signature,
                    Exceptions    = method.Exceptions,
                    Scope         = method.Scope,
                    IsStatic      = method.Static,
                    Syntax        = method.Syntax,
                    Parameters    = method.Parameters,
                    IsConstructor = method.IsConstructor,
                    IsInherited   = method.IsInherited,
                },

                Remarks = method.Remarks,
                Example = method.Example,
                SeeAlso = method.SeeAlso,

                ParentId = parentClassTopic?.Id
            };

            topic.Parent = parentClassTopic;
            topic.CreateRelativeSlugAndLink(topic);
            topic.Body = method.HelpText;

            parentClassTopic?.Topics.Add(topic);



            return(topic);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Creates a new instance of an ObjectTemplate
        /// </summary>
        /// <param name="Name">The name of this object</param>
        /// <param name="Token">The ConFile token</param>
        public ObjectTemplate(string Name, Token Token) : base(Name, Token)
        {
            // === Create method instances
            CreateComponent = new ObjectMethod<string>(Method_CreateComponent);
            AddTemplate = new ObjectMethod<string>(Method_AddTemplate);
            SetPosition = new ObjectMethod<string>(Method_SetPosition);
            SetRotation = new ObjectMethod<string>(Method_SetRotation);
            // ===

            // Grab this derived type information
            Type type = this.GetType();

            // Map components that are used in this template
            if (!ComponentMap.ContainsKey(type.Name))
            {
                Dictionary<string, PropertyInfo> properties = new Dictionary<string, PropertyInfo>();
                PropertyInfo[] fields = type.GetProperties(
                    BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic
                );

                // Loop through each property, and search for the custom attribute
                foreach (PropertyInfo property in fields)
                {
                    // If the Custom attribute exists, we add it to the Mapping
                    Attribute attribute = Attribute.GetCustomAttribute(property, typeof(Component));
                    if (attribute != null)
                    {
                        Component fieldAttr = attribute as Component;
                        foreach (string cType in fieldAttr.Types)
                            properties[cType] = property;
                    }
                }

                // [name] => array of component types that are used in this template
                ComponentMap[type.Name] = properties;
            }
        }
Ejemplo n.º 11
0
Archivo: Fun.cs Proyecto: MechWipf/lrpc
        /// <summary>
        /// call the registered method
        /// </summary>
        /// <param name="que">the queue generated by fun</param>
        /// <returns>serialize error messages or call results into a queue</returns>
        public ByteQue Invoke(ByteQue que)
        {
            byte[] arr = new byte[que.PopSize()];
            for (int i = 0; i < arr.Length; ++i)
            {
                arr[i] = que.Pop <byte>();
            }
            string name = Encoding.UTF8.GetString(arr);

            if (!funs.ContainsKey(name))
            {
                return(Except(name + " function not found"));
            }
            ObjectMethod om = funs[name];

            ParameterInfo[] types = om.fun.GetParameters();
            object[]        args  = new object[types.Length];
            for (int i = 0; i < types.Length; ++i)
            {
                Type type = types[i].ParameterType;
                if (que.Len == 0)
                {
                    return(Except("error when calling function " + name + " to restore parameters to the " + i + "th parameter " + type.ToString()));
                }
                try
                {
                    args[i] = que.Pop(type);
                }
                catch (Exception e)
                {
                    return(Except("error when calling function " + name + " to restore parameters to the " + i + "th parameter " + type.ToString() + ": " + e.ToString()));
                }
            }
            if (que.Len != 0)
            {
                return(Except("error when calling function " + name + " to restore parameters"));
            }
            ByteQue ret = new ByteQue();
            object  rst;

            try
            {
                rst = om.fun.Invoke(om.obj, args);
            }
            catch (Exception e)
            {
                return(Except("error calling function " + name + " " + e.ToString()));
            }
            ret.Push(false);
            Type rtp = om.fun.ReturnType;

            if (rtp != typeof(void))
            {
                try
                {
                    ret.Push(rtp, rst);
                }
                catch (Exception e)
                {
                    return(Except("error calling function " + name + " to store result " + e.ToString()));
                }
            }
            return(ret);
        }
        public ObjectMethod[] GetShortcutMethod(string ticketId)
        {
            var al = new ObjectMethod[1];

            return(al);
        }
Ejemplo n.º 13
0
 public Armor(string name, Token token) : base(name, token)
 {
     // Instantiate Object Methods
     AddArmorEffect = new ObjectMethod<int, string, string, string>(Method_AddArmorEffect);
     AddArmorEffectSpectacular = new ObjectMethod<int, string, string, string>(
         Method_AddArmorEffectSpectacular
     );
 }