Exemplo n.º 1
0
 public void LoadConfig(FXmlNode config)
 {
     _name = config[PTY_NAME];
     RString.CheckEmpty(_name, "name");
     _class = config[PTY_CLASS];
     RString.CheckEmpty(_class, "class");
     RClass.Exists(_class);
 }
Exemplo n.º 2
0
        public T AllocClient <T>()
            where T : IInfoClient
        {
            T client = RClass.CreateInstance <T>();

            client.Connect(_host, _port);
            return(client);
        }
Exemplo n.º 3
0
 //============================================================
 // <T>追加类的转储信息。</T>
 //
 // @param dump 转储信息
 // @param level 转储级别
 // @param refer 引用对象
 //============================================================
 public static void AppendClass(FString dump, EDumpLevel level, object refer)
 {
     if (level >= EDumpLevel.Normal)
     {
         RClass.Dump(dump, refer);
         dump.Append(' ');
     }
 }
Exemplo n.º 4
0
 public void Link(FieldInfo field)
 {
     _name  = field.Name;
     _field = field;
     _face  = RClass.Find(field.FieldType);
     if (!_face.Type.IsInterface)
     {
         throw new FFatalException("Linker must is interface. ({0}={1})", _name, _face.Type.FullName);
     }
 }
Exemplo n.º 5
0
 //============================================================
 // <T>加载设置信息。</T>
 //
 // @param config 设置信息
 //============================================================
 public void LoadConfig(FXmlNode config)
 {
     // 获得名称
     _name = config[PTY_NAME];
     RString.CheckEmpty(_name, "name");
     // 获得类型
     _typeName = config[PTY_TYPE];
     RString.CheckEmpty(_typeName, "type");
     // 获得类对象
     _type = RClass.Find(_typeName);
 }
Exemplo n.º 6
0
        public FType FindType(string name)
        {
            int count = Count;

            for (int n = count - 1; n >= 0; n--)
            {
                Type type = Get(n).LinkAssembly.GetType(name);
                if (type != null)
                {
                    return(RClass.Find(type));
                }
            }
            throw new FFatalException("Can't find reference type [{0}]", name);
        }
Exemplo n.º 7
0
        private void btnGenerate_Click(object sender, EventArgs e)
        {
            string key     = this.serialNo.Text.Trim();
            string proName = this.projectName.Text.Trim();
            string regDate = this.registerDate.Text.Trim();

            if (!checkKey(key))
            {
                return;
            }

            string value = RClass.Encryptor(key + ";" + proName + ";" + regDate);

            string path = AppDomain.CurrentDomain.BaseDirectory + @"\" + DateTime.Now.ToString("yyyy-MM-dd") + "_" + proName + @"\Register.re";

            WriteTxt(path, @"\Register.re", value);

            MessageBox.Show("生成成功!");
        }
Exemplo n.º 8
0
 public override void LoadConfig(FXmlNode config)
 {
     // Name
     _name = config[PTY_NAME];
     RString.CheckEmpty(_name, "name");
     // Type
     _typeName = config[PTY_TYPE];
     RString.CheckEmpty(_typeName, "typeName");
     _linkType = _console.FindType(_typeName);
     // Collection
     if (config.Contains(PTY_COLLECTION))
     {
         _collectionName = config[PTY_COLLECTION];
         RString.CheckEmpty(_collectionName, "collectionName");
         _linkCollection = _console.FindType(_collectionName);
     }
     else
     {
         _linkCollection = RClass.Find(typeof(XAopNodeCollection <IAopNode>));
         _collectionName = _linkCollection.Type.FullName;
     }
 }
Exemplo n.º 9
0
 public AProxyTypeAttribute(Type factoryType)
 {
     _factory = RClass.CreateInstance <IAopProxyFactory>(factoryType);
 }
Exemplo n.º 10
0
 public IValidator CreateInstance()
 {
     return((IValidator)RClass.CreateInstance(_class));
 }
Exemplo n.º 11
0
        public static void TestRClass()
        {
            var rClass = new RClass <RCase>();

            Console.WriteLine(rClass.ToString());
        }
Exemplo n.º 12
0
 public T CreateInstance <T>()
 {
     return((T)RClass.CreateInstance(_linkType.Type));
 }
Exemplo n.º 13
0
 public T CreateCollection <T>()
 {
     return((T)RClass.CreateInstance(_linkCollection.Type));
 }
Exemplo n.º 14
0
 //============================================================
 // <T>创建对象实例。</T>
 //
 // @param T 类型
 // @return 对象实例
 //============================================================
 public T CreateInstance <T>()
     where T : IXmlObject
 {
     return(RClass.CreateInstance <T>(_type.Type));
 }
Exemplo n.º 15
0
 public object CreateInstance(params object[] args)
 {
     return(RClass.CreateInstance(_linkType.Type, args));
 }
Exemplo n.º 16
0
 //============================================================
 // <T>创建单件管理器。</T>
 //============================================================
 public static void Create()
 {
     _instance = RClass.CreateInstance <T>();
 }
Exemplo n.º 17
0
        private void CreateFunction(List <string> dataMass)
        {
            GLOBALS.Functions.Clear();
            dataMass.RemoveAll(i => string.IsNullOrEmpty(i.Trim()));

            // split using ';' char and remove comment (#,=begin,=end)
            var  nDataMass = new List <string>();
            bool comment   = false;

            foreach (var dataItem in dataMass)
            {
                // remove string
                var item = " " + EncodeString(dataItem) + " ";


                // remove comment
                if (item.Contains("#"))
                {
                    var p = item.IndexOf('#');
                    item = item.Substring(0, p);
                }

                if (item.Contains("=begin "))
                {
                    comment = true;
                }

                if (!comment)
                {
                    if (item.Contains(";"))
                    {
                        nDataMass.AddRange(item.Split(';').Select(DecodeString));
                    }
                    else
                    {
                        nDataMass.Add(DecodeString(item));
                    }
                }

                if (item.Contains("=end "))
                {
                    comment = false;
                }
            }
            dataMass = nDataMass;



            int ifLevel = 0;

            RModule      rmodule  = null;
            RClass       rclass   = null;
            FunctionItem func     = null;
            var          baseFunc = new FunctionItem()
            {
                Id = Guid.NewGuid(), Name = "*" + Guid.NewGuid(), Code = new List <string>(), Parameters = new List <string>()
            };

            int funcDeep   = -1;
            int classDeep  = -1;
            int moduleDeep = -1;
            int lineNumber = 0;

            var manageWords = new string[] { " if ", " unless ", " each ", " for ", " while ", " do " };
            var attrs       = new string[] { "attr_reader ", "attr_writer ", "attr_accessor " };

            foreach (var dataItem in dataMass)
            {
                lineNumber++;
                //var bufOrig = dataItem.Trim();
                var buf = " " + EncodeString(dataItem.Trim()) + " ";

                if (buf.Contains("module"))
                {
                    moduleDeep = ++ifLevel;
                    var s    = (buf.IndexOf("module") + 6);
                    var name = buf.Substring(s, buf.Length - s).Trim();

                    if (!char.IsUpper(name[0]))
                    {
                        throw new Exception("class/module name must be CONSTANT");
                    }

                    rmodule = new RModule()
                    {
                        Name = name, ClassList = new List <RClass>()
                    };
                }


                if (buf.Contains("class"))
                {
                    classDeep = ++ifLevel;
                    var s    = (buf.IndexOf("class") + 6);
                    var name = buf.Substring(s, buf.Length - s).Trim();

                    if (!char.IsUpper(name[0]))
                    {
                        throw new Exception("class/module name must be CONSTANT");
                    }

                    rclass = new RClass()
                    {
                        Name         = name,
                        FunctionList = new List <FunctionItem>(),
                        Properties   = new List <Properties>(),
                    };
                }


                if (buf.Contains("def"))
                {
                    //var funcName = buf.Remove(buf.IndexOf("def"), 3).Trim();
                    var funcNameWithParam = new List <string>(buf.Split(' '));
                    funcNameWithParam.RemoveAll(string.IsNullOrEmpty);
                    var param = new List <string> (funcNameWithParam.Skip(2));
                    //for (int i = 2; i < funcNameWithParam.Count; i++) param.Add(funcNameWithParam[i]);

                    var name     = funcNameWithParam[1];
                    var isStatic = (name.Contains("self."));
                    name = name.Replace("self.", "");

                    func = new FunctionItem()
                    {
                        Name = name,
                        Code = new List <string>(), Id = Guid.NewGuid(), Parameters = param, IsStatic = isStatic
                    };
                    funcDeep = ++ifLevel;
                }


                if (attrs.Any(buf.Contains))
                {
                    var type = AttrAccess.Read;
                    if (attrs.Contains("attr_accessor"))
                    {
                        type = AttrAccess.ReadWrite;
                    }
                    if (attrs.Contains("attr_reader"))
                    {
                        type = AttrAccess.Read;
                    }
                    if (attrs.Contains("attr_writer"))
                    {
                        type = AttrAccess.Write;
                    }

                    var b    = buf.Replace("attr_accessor", "").Replace("attr_reader", "").Replace("attr_writer", "").Trim();
                    var list = new List <string>(b.Split(','));
                    list.RemoveAll(string.IsNullOrEmpty);

                    foreach (var l in list)
                    {
                        var p = new Properties()
                        {
                            Name = l.Trim(), Access = type
                        };
                        rclass.Properties.Add(p);
                    }
                }



                if (manageWords.Any(buf.Contains))
                {
                    ifLevel++;
                }



                // adding base execute code
                if (!buf.Contains("def") && !buf.Contains("class") && !buf.Contains("module") &&
                    !((ifLevel == funcDeep || ifLevel == classDeep || ifLevel == moduleDeep) && buf.Contains("end")) &&
                    buf.Length > 0)
                {
                    if (func != null)
                    {
                        func.Code.Add(DecodeString(buf));
                    }
                    else
                    {
                        baseFunc.Code.Add(DecodeString(buf));
                    }
                }



                if (buf.Contains("end"))
                {
                    // end of function
                    if (ifLevel == funcDeep)
                    {
                        if (func == null)
                        {
                            throw new Exception("ParceError. Finded end of function, but function not initialized!");
                        }

                        if (rclass != null)
                        {
                            rclass.FunctionList.Add(func.Clone() as FunctionItem);
                        }
                        else
                        {
                            GLOBALS.Functions.Add(func.Clone() as FunctionItem);
                        }

                        func = null;
                    }

                    // end of class
                    if (ifLevel == classDeep)
                    {
                        if (rclass == null)
                        {
                            throw new Exception("ParceError. Finded end of Class, but he not initialized!");
                        }

                        if (rmodule == null)
                        {
                            GLOBALS.RClassesList.Add(rclass.Clone() as RClass);
                            rclass = null;
                        }
                        else
                        {
                            rmodule.ClassList.Add(rclass.Clone() as RClass);
                            rclass = null;
                        }
                    }

                    // end of module
                    if (ifLevel == moduleDeep)
                    {
                        if (rmodule == null)
                        {
                            throw new Exception("ParceError. Finded end of Module, but he not initialized!");
                        }
                        GLOBALS.RModuleList.Add(rmodule);
                        rmodule = null;
                    }

                    if (ifLevel >= 0)
                    {
                        ifLevel--;
                    }
                    else
                    {
                        throw new Exception("ParceError. Detected unexpected 'end' ");
                    }
                }
            }


            if (baseFunc.Code.Count > 0)
            {
                ExecuteFunction(baseFunc.Name);
            }
        }
Exemplo n.º 18
0
 public object CreateInstance()
 {
     return(RClass.CreateInstance(_linkType.Type));
 }
Exemplo n.º 19
0
 public void LoadConfig(FXmlNode config)
 {
     _name      = config[PTY_NAME];
     _className = config[PTY_CLASS];
     _class     = RClass.Find(_className);
 }
Exemplo n.º 20
0
 public FAdObject CreateInstance()
 {
     return(RClass.CreateInstance <FAdObject>(_class.Type));
 }
Exemplo n.º 21
0
        public void LinkInterfaces(FAopComponentBuilder builder)
        {
            XAopComponent  xcomponent = builder.Component;
            FAopDescriptor descriptor = xcomponent.Descriptor;

            if (descriptor.HasLinker)
            {
                foreach (FAopLinker linker in descriptor.Linkers.Values)
                {
                    // Find
                    object find = null;
                    if (builder.Faces.Contains(linker.Face.FullName))
                    {
                        find = builder.Faces[linker.Face.FullName];
                    }
                    else
                    {
                        find = _components.Find(linker.Face.Type);
                        builder.Faces[linker.Face.FullName] = find;
                    }
                    // Check
                    if (find == null)
                    {
                        if (_logger.WarnAble)
                        {
                            _logger.Warn(this, "LinkInterfaces", "Linker instance is null. {0}", linker.Name);
                        }
                    }
                    else
                    {
                        if (_logger.DebugAble)
                        {
                            _logger.Debug(this, "LinkInterfaces", "Set linker {0} = {1}", linker.Name, RClass.Dump(find));
                        }
                        linker.Field.SetValue(builder.Instance, find);
                    }
                }
            }
        }