Exemplo n.º 1
0
        private void GetCellMethods(EntityDef entity, ArrayList methods)
        {
            Dictionary <ushort, EntityDefMethod> dictionary  = new Dictionary <ushort, EntityDefMethod>();
            Dictionary <string, EntityDefMethod> dictionary2 = new Dictionary <string, EntityDefMethod>();

            if (methods != null)
            {
                ushort num = 0;
                foreach (SecurityElement element in methods)
                {
                    if (((element.Children != null) && (element.Children.Count != 0)) && ((element.Children[0] as SecurityElement).Tag == "Exposed"))
                    {
                        EntityDefMethod method = new EntityDefMethod {
                            FuncName = element.Tag,
                            FuncID   = num,
                            ArgsType = new List <VObject>()
                        };
                        for (int i = 1; i < element.Children.Count; i++)
                        {
                            SecurityElement element2 = element.Children[i] as SecurityElement;
                            method.ArgsType.Add(TypeMapping.GetVObject(element2.Text.Trim()));
                        }
                        dictionary.Add(method.FuncID, method);
                        if (!dictionary2.ContainsKey(method.FuncName))
                        {
                            dictionary2.Add(method.FuncName, method);
                        }
                    }
                    num = (ushort)(num + 1);
                }
            }
            entity.CellMethodsByID   = dictionary;
            entity.CellMethodsByName = dictionary2;
        }
Exemplo n.º 2
0
        private EntityDef ParseDef(ArrayList xmlRoot)
        {
            var etyDef = new EntityDef();

            foreach (SecurityElement element in xmlRoot)
            {
                if (element.Tag == EL_PARENT)
                {
                    etyDef.ParentName = element.Text.Trim(); //To do: Trim()优化
                }
                else if (element.Tag == ATTR_CLIENT_METHODS)
                {
                    GetClientMethods(etyDef, element.Children);
                }
                else if (element.Tag == ATTR_BASE_METHODS)
                {
                    GetBaseMethods(etyDef, element.Children);
                }
                else if (element.Tag == ATTR_CELL_METHODS)
                {
                    GetCellMethods(etyDef, element.Children);
                }
                else if (element.Tag == ATTR_PROPERTIES)
                {
                    etyDef.Properties          = GetProperties(element.Children);
                    etyDef.PropertiesIdMapping = new Dictionary <string, ushort>();
                    foreach (var item in etyDef.Properties)
                    {
                        etyDef.PropertiesIdMapping.Add(item.Value.Name, item.Key);
                    }
                    etyDef.PropertiesList = etyDef.Properties.Values.ToList();
                }
            }
            return(etyDef);
        }
Exemplo n.º 3
0
        private EntityDef ParseDef(ArrayList xmlRoot)
        {
            EntityDef etyDef = new EntityDef();

            foreach (SecurityElement element in xmlRoot)
            {
                if (element.Tag == EL_PARENT)
                {
                    etyDef.ParentName = element.Text.Trim();//To do: Trim()优化
                }
                else if (element.Tag == ATTR_CLIENT_METHODS)
                {
                    GetClientMethods(etyDef, element.Children);
                }
                else if (element.Tag == ATTR_BASE_METHODS)
                {
                    GetBaseMethods(etyDef, element.Children);
                }
                else if (element.Tag == ATTR_CELL_METHODS)
                {
                    GetCellMethods(etyDef, element.Children);
                }
                else if (element.Tag == ATTR_PROPERTIES)
                {
                    etyDef.Properties     = GetProperties(element.Children);
                    etyDef.PropertiesList = etyDef.Properties.Values.ToList();
                }
            }
            return(etyDef);
        }
Exemplo n.º 4
0
        private EntityDef ParseHmfDef(Dictionary <object, object> def)
        {
            EntityDef etyDef = new EntityDef();

            foreach (KeyValuePair <object, object> pair in def)
            {
                if (((string)pair.Key) != "Parent")
                {
                    if (((string)pair.Key) == "ClientMethods")
                    {
                        this.GetHmfClientMethods(etyDef, (List <object>)pair.Value);
                    }
                    else if (((string)pair.Key) == "BaseMethods")
                    {
                        this.GetHmfBaseMethods(etyDef, (List <object>)pair.Value);
                    }
                    else if (((string)pair.Key) == "CellMethods")
                    {
                        this.GetHmfCellMethods(etyDef, (List <object>)pair.Value);
                    }
                    else if (((string)pair.Key) == "Properties")
                    {
                        etyDef.Properties     = this.GetHmfProperties((List <object>)pair.Value);
                        etyDef.PropertiesList = etyDef.Properties.Values.ToList <EntityDefProperties>();
                    }
                }
            }
            return(etyDef);
        }
Exemplo n.º 5
0
        private EntityDef ParseDef(ArrayList xmlRoot)
        {
            EntityDef entity = new EntityDef();

            foreach (SecurityElement element in xmlRoot)
            {
                if (element.Tag == "Parent")
                {
                    entity.ParentName = element.Text.Trim();
                }
                else if (element.Tag == "ClientMethods")
                {
                    this.GetClientMethods(entity, element.Children);
                }
                else if (element.Tag == "BaseMethods")
                {
                    this.GetBaseMethods(entity, element.Children);
                }
                else if (element.Tag == "CellMethods")
                {
                    this.GetCellMethods(entity, element.Children);
                }
                else if (element.Tag == "Properties")
                {
                    entity.Properties     = this.GetProperties(element.Children);
                    entity.PropertiesList = entity.Properties.Values.ToList <EntityDefProperties>();
                }
            }
            return(entity);
        }
Exemplo n.º 6
0
        private EntityDef ParseHmfDef(Dictionary <object, object> def)
        {
            EntityDef etyDef = new EntityDef();

            foreach (var element in def)
            {
                if ((string)element.Key == EL_PARENT)
                {
                    //etyDef.ParentName = element.Text.Trim();//To do: Trim()优化
                }
                else if ((string)element.Key == ATTR_CLIENT_METHODS)
                {
                    GetHmfClientMethods(etyDef, (List <object>)element.Value);
                }
                else if ((string)element.Key == ATTR_BASE_METHODS)
                {
                    GetHmfBaseMethods(etyDef, (List <object>)element.Value);
                }
                else if ((string)element.Key == ATTR_CELL_METHODS)
                {
                    GetHmfCellMethods(etyDef, (List <object>)element.Value);
                }
                else if ((string)element.Key == ATTR_PROPERTIES)
                {
                    etyDef.Properties     = GetHmfProperties((List <object>)element.Value);
                    etyDef.PropertiesList = etyDef.Properties.Values.ToList();
                }
            }
            return(etyDef);
        }
Exemplo n.º 7
0
        private void GetHmfClientMethods(EntityDef etyDef, List <object> methods)
        {
            Dictionary <ushort, EntityDefMethod> dictionary  = new Dictionary <ushort, EntityDefMethod>();
            Dictionary <string, EntityDefMethod> dictionary2 = new Dictionary <string, EntityDefMethod>();

            if (methods != null)
            {
                ushort num = 0;
                for (int i = 0; i < methods.Count; i++)
                {
                    EntityDefMethod method             = new EntityDefMethod();
                    KeyValuePair <object, object> pair = ((Dictionary <object, object>)methods[i]).First <KeyValuePair <object, object> >();
                    method.FuncName = (string)pair.Key;
                    method.FuncID   = num;
                    method.ArgsType = new List <VObject>();
                    if (pair.Value != null)
                    {
                        foreach (object obj2 in (List <object>)pair.Value)
                        {
                            List <object> list = (List <object>)obj2;
                            method.ArgsType.Add(TypeMapping.GetVObject(((string)list[1]).Trim()));
                        }
                    }
                    dictionary.Add(method.FuncID, method);
                    if (!dictionary2.ContainsKey(method.FuncName))
                    {
                        dictionary2.Add(method.FuncName, method);
                    }
                    num = (ushort)(num + 1);
                }
            }
            etyDef.ClientMethodsByID   = dictionary;
            etyDef.ClientMethodsByName = dictionary2;
        }
Exemplo n.º 8
0
        private void GetHmfClientMethods(EntityDef etyDef, List <object> methods)
        {
            Dictionary <ushort, EntityDefMethod> methodByIDList   = new Dictionary <ushort, EntityDefMethod>();
            Dictionary <string, EntityDefMethod> methodByNameList = new Dictionary <string, EntityDefMethod>();

            if (methods != null)
            {
                ushort index = 0;//方法索引
                for (int i = 0; i < methods.Count; i++)
                {
                    EntityDefMethod               m   = new EntityDefMethod();
                    Dictionary <object, object>   fun = (Dictionary <object, object>)methods[i];
                    KeyValuePair <object, object> kv  = fun.First();
                    m.FuncName = (string)kv.Key;
                    m.FuncID   = index;
                    m.ArgsType = new List <VObject>();
                    if (kv.Value != null)
                    {
                        foreach (var args in (List <object>)kv.Value)
                        {
                            List <object> funargs = (List <object>)args;
                            m.ArgsType.Add(TypeMapping.GetVObject(((string)funargs[1]).Trim()));//To do: Trim()优化
                        }
                    }
                    methodByIDList.Add(m.FuncID, m);
                    if (!methodByNameList.ContainsKey(m.FuncName))
                    {
                        methodByNameList.Add(m.FuncName, m);
                    }
                    index++;
                }
            }
            etyDef.ClientMethodsByID   = methodByIDList;
            etyDef.ClientMethodsByName = methodByNameList;
        }
Exemplo n.º 9
0
        private void GetClientMethods(EntityDef entity, ArrayList methods)
        {
            Dictionary <ushort, EntityDefMethod> dictionary  = new Dictionary <ushort, EntityDefMethod>();
            Dictionary <string, EntityDefMethod> dictionary2 = new Dictionary <string, EntityDefMethod>();

            if (methods != null)
            {
                ushort num = 0;
                foreach (SecurityElement element in methods)
                {
                    EntityDefMethod method = new EntityDefMethod {
                        FuncName = element.Tag,
                        FuncID   = num,
                        ArgsType = new List <VObject>()
                    };
                    if (element.Children != null)
                    {
                        foreach (SecurityElement element2 in element.Children)
                        {
                            method.ArgsType.Add(TypeMapping.GetVObject(element2.Text.Trim()));
                        }
                    }
                    dictionary.Add(method.FuncID, method);
                    if (!dictionary2.ContainsKey(method.FuncName))
                    {
                        dictionary2.Add(method.FuncName, method);
                    }
                    num = (ushort)(num + 1);
                }
            }
            entity.ClientMethodsByID   = dictionary;
            entity.ClientMethodsByName = dictionary2;
        }
Exemplo n.º 10
0
 public EntityDefMethod TryGetBaseMethod(string name, EntityDef entity)
 {
     if (entity == null)
     {
         return(null);
     }
     if (entity.BaseMethodsByName != null && entity.BaseMethodsByName.ContainsKey(name))
     {
         return(entity.BaseMethodsByName[name]);
     }
     return(TryGetBaseMethod(name, entity.Parent));
 }
Exemplo n.º 11
0
 public EntityDefMethod TryGetCellMethod(ushort id, EntityDef entity)
 {
     if (entity == null)
     {
         return(null);
     }
     if (entity.CellMethodsByID != null && entity.CellMethodsByID.ContainsKey(id))
     {
         return(entity.CellMethodsByID[id]);
     }
     return(TryGetCellMethod(id, entity.Parent));
 }
Exemplo n.º 12
0
        /// <summary>
        /// 将远程方法调用编码为二进制数组。
        /// </summary>
        /// <param name="args">参数列表</param>
        /// <returns>编码后的二进制数组</returns>
        public Byte[] Encode(params Object[] args)
        {
            EntityDef ety = CurrentEntity;//DefParser.Instance.GetEntityByName(EntityName);

            if (ety == null)
            {
                throw new DefineParseException(String.Format("Encode error: CurrentEntity is null."));
            }

            EntityDefMethod method = svrMethod;

            FuncID = method.FuncID;

            if (method.ArgsType.Count != args.Length)
            {
                throw new DefineParseException(String.Format("Encode error: The number of parameters is not match. func: {0}, require num: {1}, current num: {2}.", FuncID, method.ArgsType.Count, args.Length));
            }
            //屏蔽类型检查,报错就报吧
            //for (int i = 0; i < method.ArgsType.Count; i++)
            //{
            //    if (!args[i].GetType().IsAssignableFrom(method.ArgsType[i].VValueType))
            //        throw new DefineParseException(String.Format("Encode error: Parameters type is not match '{0}' in entity '{1}' of index '{2}'.", FuncID, ety.Name, i));
            //}

            if (toCell)
            {
                Push(VUInt16.Instance.Encode(MSGIDType.BASEAPP_CLIENT_RPC2CELL_VIA_BASE));
                Push(VUInt16.Instance.Encode(FuncID));
                for (int j = 0; j < args.Length; j++)
                {
                    Push(method.ArgsType[j].Encode(args[j]));
                }

                Byte[] cellRst = new Byte[m_unLen];
                Buffer.BlockCopy(m_szBuff, 0, cellRst, 0, m_unLen);
                EndPluto(cellRst);
                return(cellRst);
            }

            Push(VUInt16.Instance.Encode(MSGIDType.BASEAPP_CLIENT_RPCALL)); // 指定 pluto 类型为 rpc
            Push(VUInt16.Instance.Encode(FuncID));                          // 指定 调用的 func 标识
            for (int i = 0; i < args.Length; i++)
            {
                Push(method.ArgsType[i].Encode(args[i]));                    // 增加参数
            }

            Byte[] result = new Byte[m_unLen];
            Buffer.BlockCopy(m_szBuff, 0, result, 0, m_unLen);
            EndPluto(result);
            return(result);
        }
Exemplo n.º 13
0
        public EntityDefMethod TryGetCellMethod(ushort id, EntityDef entity)
        {
            EntityDefMethod method = null;

            if (entity != null)
            {
                entity.CellMethodsByID.TryGetValue(id, out method);
                if (method == null)
                {
                    return(this.TryGetCellMethod(id, entity.Parent));
                }
            }
            return(method);
        }
Exemplo n.º 14
0
        public EntityDefMethod TryGetCellMethod(string name, EntityDef entity)
        {
            EntityDefMethod method = null;

            if (entity != null)
            {
                entity.CellMethodsByName.TryGetValue(name, out method);
                if (method == null)
                {
                    return(this.TryGetCellMethod(name, entity.Parent));
                }
            }
            return(method);
        }
Exemplo n.º 15
0
 private void ParseEntitiesHmf(Dictionary <object, object> def, String etyName, ushort entityID)
 {
     if (def != null && def.Count != 0)
     {
         EntityDef etyDef = ParseHmfDef(def);
         etyDef.ID   = entityID;
         etyDef.Name = etyName;
         if (!m_entitysByName.ContainsKey(etyDef.Name))
         {
             m_entitysByName.Add(etyDef.Name, etyDef);
         }
         if (!m_entitysByID.ContainsKey(etyDef.ID))
         {
             m_entitysByID.Add(etyDef.ID, etyDef);
         }
     }
 }
Exemplo n.º 16
0
 private void ParseEntitiesHmf(Dictionary <object, object> def, string etyName, ushort entityID)
 {
     if ((def != null) && (def.Count != 0))
     {
         EntityDef def2 = this.ParseHmfDef(def);
         def2.ID   = entityID;
         def2.Name = etyName;
         if (!this.m_entitysByName.ContainsKey(def2.Name))
         {
             this.m_entitysByName.Add(def2.Name, def2);
         }
         if (!this.m_entitysByID.ContainsKey(def2.ID))
         {
             this.m_entitysByID.Add(def2.ID, def2);
         }
     }
 }
Exemplo n.º 17
0
        private void ParseEntitiesXml(SecurityElement xmlDoc, String etyName, ushort entityID)
        {
            ArrayList xmlRoot = xmlDoc.Children;

            if (xmlRoot != null && xmlRoot.Count != 0)
            {
                EntityDef etyDef = ParseDef(xmlRoot);
                etyDef.ID   = entityID;
                etyDef.Name = etyName;
                if (!m_entitysByName.ContainsKey(etyDef.Name))
                {
                    m_entitysByName.Add(etyDef.Name, etyDef);
                }
                if (!m_entitysByID.ContainsKey(etyDef.ID))
                {
                    m_entitysByID.Add(etyDef.ID, etyDef);
                }
            }
        }
Exemplo n.º 18
0
        private void ParseEntitiesXml(SecurityElement xmlDoc, string etyName, ushort entityID)
        {
            ArrayList children = xmlDoc.Children;

            if ((children != null) && (children.Count != 0))
            {
                EntityDef def = this.ParseDef(children);
                def.ID   = entityID;
                def.Name = etyName;
                if (!this.m_entitysByName.ContainsKey(def.Name))
                {
                    this.m_entitysByName.Add(def.Name, def);
                }
                if (!this.m_entitysByID.ContainsKey(def.ID))
                {
                    this.m_entitysByID.Add(def.ID, def);
                }
            }
        }
Exemplo n.º 19
0
        private void GetCellMethods(EntityDef entity, ArrayList methods)
        {
            var methodByIDList   = new Dictionary <ushort, EntityDefMethod>();
            var methodByNameList = new Dictionary <string, EntityDefMethod>();

            if (methods != null)
            {
                ushort index = 0; //方法索引
                foreach (SecurityElement element in methods)
                {
                    //判断方法参数是否为空,或者第一个Tag是否标记为公开方法
                    if (element.Children != null && element.Children.Count != 0 &&
                        (element.Children[0] as SecurityElement).Tag == EL_EXPOSED)
                    {
                        var m = new EntityDefMethod();
                        m.FuncName = element.Tag;
                        m.FuncID   = index;
                        m.ArgsType = new List <VObject>();
                        for (var i = 1; i < element.Children.Count; i++) //跳过第一个Tag字段
                        {
                            var args = element.Children[i] as SecurityElement;
                            m.ArgsType.Add(TypeMapping.GetVObject(args.Text.Trim())); //To do: Trim()优化
                        }

                        //if (!methodByIDList.ContainsKey(index))
                        methodByIDList.Add(m.FuncID, m);
                        if (!methodByNameList.ContainsKey(m.FuncName))
                        {
                            methodByNameList.Add(m.FuncName, m);
                        }
                    }
                    index++;
                }
            }
            //entity.BaseMethodsByID = methodByIDList;
            //entity.BaseMethodsByName = methodByNameList;
            entity.CellMethodsByID   = methodByIDList;
            entity.CellMethodsByName = methodByNameList;
            //return methodByIDList;
        }
Exemplo n.º 20
0
        private void GetHmfBaseMethods(EntityDef etyDef, List <object> methods)
        {
            Dictionary <ushort, EntityDefMethod> methodByIDList   = new Dictionary <ushort, EntityDefMethod>();
            Dictionary <string, EntityDefMethod> methodByNameList = new Dictionary <string, EntityDefMethod>();

            if (methods != null)
            {
                ushort index = 0;//方法索引
                for (int i = 0; i < methods.Count; i++)
                {
                    //判断方法参数是否为空,或者第一个Tag是否标记为公开方法
                    Dictionary <object, object>   fun = (Dictionary <object, object>)methods[i];
                    KeyValuePair <object, object> kv  = fun.First();
                    List <object> v = (List <object>)kv.Value;
                    if (v != null && v.Count != 0 && (string)((List <object>)v[0])[0] == EL_EXPOSED)
                    {
                        EntityDefMethod m = new EntityDefMethod();
                        m.FuncName = (string)kv.Key;
                        m.FuncID   = index;
                        m.ArgsType = new List <VObject>();
                        for (int j = 1; j < v.Count; j++)//跳过第一个Tag字段
                        {
                            List <object> args = (List <object>)v[j];
                            m.ArgsType.Add(TypeMapping.GetVObject(((string)args[1]).Trim()));//To do: Trim()优化
                        }

                        //if (!methodByIDList.ContainsKey(index))
                        methodByIDList.Add(m.FuncID, m);
                        if (!methodByNameList.ContainsKey(m.FuncName))
                        {
                            methodByNameList.Add(m.FuncName, m);
                        }
                    }
                    index++;
                }
            }
            etyDef.BaseMethodsByID   = methodByIDList;
            etyDef.BaseMethodsByName = methodByNameList;
        }
Exemplo n.º 21
0
        private void GetClientMethods(EntityDef entity, ArrayList methods)
        {
            var methodByIDList   = new Dictionary <ushort, EntityDefMethod>();
            var methodByNameList = new Dictionary <string, EntityDefMethod>();

            if (methods != null)
            {
                ushort index = 0; //方法索引
                foreach (SecurityElement element in methods)
                {
                    //if (element.NodeType == XmlNodeType.Comment)
                    //    continue;
                    var m = new EntityDefMethod();
                    m.FuncName = element.Tag;
                    m.FuncID   = index;
                    m.ArgsType = new List <VObject>();

                    if (element.Children != null)
                    {
                        foreach (SecurityElement args in element.Children)
                        {
                            //    if (args != null && args.NodeType == XmlNodeType.Element)

                            m.ArgsType.Add(TypeMapping.GetVObject(args.Text.Trim())); //To do: Trim()优化
                        }
                    }
                    //if (!methodList.ContainsKey(index))
                    methodByIDList.Add(m.FuncID, m);
                    if (!methodByNameList.ContainsKey(m.FuncName))
                    {
                        methodByNameList.Add(m.FuncName, m);
                    }
                    index++;
                }
            }
            entity.ClientMethodsByID   = methodByIDList;
            entity.ClientMethodsByName = methodByNameList;
            //return methodList;
        }
Exemplo n.º 22
0
        private void GetHmfCellMethods(EntityDef etyDef, List <object> methods)
        {
            Dictionary <ushort, EntityDefMethod> dictionary  = new Dictionary <ushort, EntityDefMethod>();
            Dictionary <string, EntityDefMethod> dictionary2 = new Dictionary <string, EntityDefMethod>();

            if (methods != null)
            {
                ushort num = 0;
                for (int i = 0; i < methods.Count; i++)
                {
                    KeyValuePair <object, object> pair = ((Dictionary <object, object>)methods[i]).First <KeyValuePair <object, object> >();
                    List <object> list = (List <object>)pair.Value;
                    if (((list != null) && (list.Count != 0)) && (((string)((List <object>)list[0])[0]) == "Exposed"))
                    {
                        EntityDefMethod method = new EntityDefMethod {
                            FuncName = (string)pair.Key,
                            FuncID   = num,
                            ArgsType = new List <VObject>()
                        };
                        for (int j = 1; j < list.Count; j++)
                        {
                            List <object> list2 = (List <object>)list[j];
                            method.ArgsType.Add(TypeMapping.GetVObject(((string)list2[1]).Trim()));
                        }
                        dictionary.Add(method.FuncID, method);
                        if (!dictionary2.ContainsKey(method.FuncName))
                        {
                            dictionary2.Add(method.FuncName, method);
                        }
                    }
                    num = (ushort)(num + 1);
                }
            }
            etyDef.CellMethodsByID   = dictionary;
            etyDef.CellMethodsByName = dictionary2;
        }
Exemplo n.º 23
0
 private EntityDef ParseDef(ArrayList xmlRoot)
 {
     EntityDef etyDef = new EntityDef();
     foreach (SecurityElement element in xmlRoot)
     {
         if (element.Tag == EL_PARENT)
         {
             etyDef.ParentName = element.Text.Trim();//To do: Trim()优化
         }
         else if (element.Tag == ATTR_CLIENT_METHODS)
         {
             GetClientMethods(etyDef, element.Children);
         }
         else if (element.Tag == ATTR_BASE_METHODS)
         {
             GetBaseMethods(etyDef, element.Children);
         }
         else if (element.Tag == ATTR_CELL_METHODS)
         {
             GetCellMethods(etyDef, element.Children);
         }
         else if (element.Tag == ATTR_PROPERTIES)
         {
             etyDef.Properties = GetProperties(element.Children);
             etyDef.PropertiesList = etyDef.Properties.Values.ToList();
         }
     }
     return etyDef;
 }
Exemplo n.º 24
0
 public EntityDefMethod TryGetCellMethod(string name, EntityDef entity)
 {
     EntityDefMethod method = null;
     if (entity != null)
     {
         entity.CellMethodsByName.TryGetValue(name, out method);
         if (method == null)
         {
             return TryGetCellMethod(name, entity.Parent);
         }
     }
     return method;
 }
Exemplo n.º 25
0
        private void GetClientMethods(EntityDef entity, ArrayList methods)
        {
            Dictionary<ushort, EntityDefMethod> methodByIDList = new Dictionary<ushort, EntityDefMethod>();
            Dictionary<string, EntityDefMethod> methodByNameList = new Dictionary<string, EntityDefMethod>();
            if (methods != null)
            {
                ushort index = 0;//方法索引
                foreach (SecurityElement element in methods)
                {
                    //if (element.NodeType == XmlNodeType.Comment)
                    //    continue;
                    EntityDefMethod m = new EntityDefMethod();
                    m.FuncName = element.Tag;
                    m.FuncID = index;
                    m.ArgsType = new List<VObject>();
                    if (element.Children != null)
                    {
                        foreach (SecurityElement args in element.Children)
                        {
                            //    if (args != null && args.NodeType == XmlNodeType.Element)
                            m.ArgsType.Add(TypeMapping.GetVObject(args.Text.Trim()));//To do: Trim()优化
                        }

                    }
                    //if (!methodList.ContainsKey(index))
                    methodByIDList.Add(m.FuncID, m);
                    if (!methodByNameList.ContainsKey(m.FuncName))
                        methodByNameList.Add(m.FuncName, m);
                    index++;
                }
            }
            entity.ClientMethodsByID = methodByIDList;
            entity.ClientMethodsByName = methodByNameList;
            //return methodList;
        }
Exemplo n.º 26
0
        private void GetCellMethods(EntityDef entity, ArrayList methods)
        {
            Dictionary<ushort, EntityDefMethod> methodByIDList = new Dictionary<ushort, EntityDefMethod>();
            Dictionary<string, EntityDefMethod> methodByNameList = new Dictionary<string, EntityDefMethod>();
            if (methods != null)
            {
                ushort index = 0;//方法索引
                foreach (SecurityElement element in methods)
                {
                    //判断方法参数是否为空,或者第一个Tag是否标记为公开方法
                    if (element.Children != null && element.Children.Count != 0 && (element.Children[0] as SecurityElement).Tag == EL_EXPOSED)
                    {
                        EntityDefMethod m = new EntityDefMethod();
                        m.FuncName = element.Tag;
                        m.FuncID = index;
                        m.ArgsType = new List<VObject>();
                        for (int i = 1; i < element.Children.Count; i++)//跳过第一个Tag字段
                        {
                            SecurityElement args = element.Children[i] as SecurityElement;
                            m.ArgsType.Add(TypeMapping.GetVObject(args.Text.Trim()));//To do: Trim()优化
                        }

                        //if (!methodByIDList.ContainsKey(index))
                        methodByIDList.Add(m.FuncID, m);
                        if (!methodByNameList.ContainsKey(m.FuncName))
                            methodByNameList.Add(m.FuncName, m);
                    }
                    index++;
                }
            }
            //entity.BaseMethodsByID = methodByIDList;
            //entity.BaseMethodsByName = methodByNameList;
            entity.CellMethodsByID = methodByIDList;
            entity.CellMethodsByName = methodByNameList;
            //return methodByIDList;
        }
Exemplo n.º 27
0
 private EntityDef ParseHmfDef(Dictionary<object, object> def)
 {
     EntityDef etyDef = new EntityDef();
     foreach (var element in def)
     {
         if ((string)element.Key == EL_PARENT)
         {
             //etyDef.ParentName = element.Text.Trim();//To do: Trim()优化
         }
         else if ((string)element.Key == ATTR_CLIENT_METHODS)
         {
             GetHmfClientMethods(etyDef, (List<object>)element.Value);
         }
         else if ((string)element.Key == ATTR_BASE_METHODS)
         {
             GetHmfBaseMethods(etyDef, (List<object>)element.Value);
         }
         else if ((string)element.Key == ATTR_CELL_METHODS)
         {
             GetHmfCellMethods(etyDef, (List<object>)element.Value);
         }
         else if ((string)element.Key == ATTR_PROPERTIES)
         {
             etyDef.Properties = GetHmfProperties((List<object>)element.Value);
             etyDef.PropertiesList = etyDef.Properties.Values.ToList();
         }
     }
     return etyDef;
 }
Exemplo n.º 28
0
 public EntityDefMethod TryGetCellMethod(ushort id, EntityDef entity)
 {
     EntityDefMethod method = null;
     if (entity != null)
     {
         entity.CellMethodsByID.TryGetValue(id, out method);
         if (method == null)
         {
             return TryGetCellMethod(id, entity.Parent);
         }
     }
     return method;
 }
Exemplo n.º 29
0
        private void GetHmfCellMethods(EntityDef etyDef, List<object> methods)
        {
            Dictionary<ushort, EntityDefMethod> methodByIDList = new Dictionary<ushort, EntityDefMethod>();
            Dictionary<string, EntityDefMethod> methodByNameList = new Dictionary<string, EntityDefMethod>();
            if (methods != null)
            {
                ushort index = 0;//方法索引
                for(int i = 0; i < methods.Count; i++)
                {
                    //判断方法参数是否为空,或者第一个Tag是否标记为公开方法
                    Dictionary<object, object> fun = (Dictionary<object, object>)methods[i];
                    KeyValuePair<object, object> kv = fun.First();
                    List<object> v = (List<object>)kv.Value;
                    if (v != null && v.Count != 0 && (string)((List<object>)v[0])[0] == EL_EXPOSED)
                    {
                        EntityDefMethod m = new EntityDefMethod();
                        m.FuncName = (string)kv.Key;
                        m.FuncID = index;
                        m.ArgsType = new List<VObject>();
                        for (int j = 1; j < v.Count; j++)//跳过第一个Tag字段
                        {
                            List<object> args = (List<object>)v[j];
                            m.ArgsType.Add(TypeMapping.GetVObject(((string)args[1]).Trim()));//To do: Trim()优化
                        }

                        methodByIDList.Add(m.FuncID, m);
                        if (!methodByNameList.ContainsKey(m.FuncName))
                            methodByNameList.Add(m.FuncName, m);
                    }
                    index++;
                }
            }
            etyDef.CellMethodsByID = methodByIDList;
            etyDef.CellMethodsByName = methodByNameList;
        }
Exemplo n.º 30
0
        private void GetHmfClientMethods(EntityDef etyDef, List<object> methods)
        {
            Dictionary<ushort, EntityDefMethod> methodByIDList = new Dictionary<ushort, EntityDefMethod>();
            Dictionary<string, EntityDefMethod> methodByNameList = new Dictionary<string, EntityDefMethod>();
            if (methods != null)
            {
                ushort index = 0;//方法索引
                for (int i = 0; i < methods.Count; i++)
                {
                    EntityDefMethod m = new EntityDefMethod();
                    Dictionary<object, object> fun = (Dictionary<object, object>)methods[i];
                    KeyValuePair<object, object> kv = fun.First();
                    m.FuncName = (string)kv.Key;
                    m.FuncID = index;
                    m.ArgsType = new List<VObject>();
                    if (kv.Value != null)
                    {
                        foreach (var args in (List<object>)kv.Value)
                        {
                            List<object> funargs = (List<object>)args;
                            m.ArgsType.Add(TypeMapping.GetVObject(((string)funargs[1]).Trim()));//To do: Trim()优化
                        }

                    }
                    methodByIDList.Add(m.FuncID, m);
                    if (!methodByNameList.ContainsKey(m.FuncName))
                        methodByNameList.Add(m.FuncName, m);
                    index++;
                }
            }
            etyDef.ClientMethodsByID = methodByIDList;
            etyDef.ClientMethodsByName = methodByNameList;
        }