public IXMLElement AddElement(string name, XMLElementUI <TAppData, TModuleData, TElementData> previewElement)
        {
            string version = previewElement.module.data.GetVersion();

            VElementHandler <TAppData, TModuleData, TElementData> .AddElementDelegate[] hs;
            if (!versions.TryGetValue(version, out hs))
            {
                hs = handlers.Select(h => h.GetMethod(version)).Where(h => h != null).ToArray();
                if (hs.Length == 0)
                {
                    throw new VersionException(this, version);
                }
                versions.Add(version, hs);
            }

            foreach (var h in hs)
            {
                var r = h(name, previewElement);
                if (!(r is FakeElement))
                {
                    return(r);
                }
            }

            return(new BombElement(name, previewElement.name));
        }
        public AddResult AddAttribute(string attributeName, string attributeValue, XMLElementUI <TAppData, TModuleData, TElementData> element)
        {
            string version = element.module.data.GetVersion();

            VAttributeHandler <TAppData, TModuleData, TElementData> .AddAttributeDelegate[] hs;
            if (!versions.TryGetValue(version, out hs))
            {
                hs = handlers.Select(h => h.GetMethod(version)).Where(h => h != null).ToArray();
                if (hs.Length == 0)
                {
                    throw new VersionException(this, version);
                }
                versions.Add(version, hs);
            }

            AddResult r = AddResult.State.Ignored;

            foreach (var h in hs)
            {
                r |= h(attributeName, attributeValue, element);
                if (!r.ignored)
                {
                    return(r);
                }
            }
            return(r);
        }
        new public AddResult AddAttribute(string attributeName, string value, XMLElementUI <TAppData, TModuleData, TElementData> element)
        {
            foreach (var go in element.data.GetGameObject().GetComponentsInChildren <Component>())
            {
                var p = go.GetType().GetProperty(attributeName, BindingFlags.Instance | BindingFlags.Public);
                if (p == null)
                {
                    continue;
                }

                try {
                    if (PropertySetter.SetValue(p, go, value, PropertySetter.Data.Create(element.data, element.module.data)))
                    {
                        return(AddResult.State.OK);
                    }
                }
                catch (Exception e)
                {
                    return(new AddResult(AddResult.State.Error)
                    {
                        message = e.Message
                    });
                }
            }
            return(AddResult.State.Ignored);
        }
Пример #4
0
        public AddResult AddAttribute(string attributeName, string attributeValue, XMLElementUI <TAppData, TModuleData, TElementData> element)
        {
            var m = GetMethod(element.module.data.GetVersion());

            if (m != null)
            {
                return(m(attributeName, attributeValue, element));
            }

            throw new VersionException(this, element.module.data.GetVersion());
        }
Пример #5
0
        new public AddResult AddAttribute(string attributeName, string value, XMLElementUI <TAppData, TModuleData, TElementData> element)
        {
            var rt = element.data.GetGameObject().GetComponent <RectTransform>();

            if (rt == null)
            {
                return(AddResult.State.Ignored);
            }
            try
            {
                switch (attributeName)
                {
                case "left":
                    Left(rt, value);
                    return(AddResult.State.OK);

                case "right":
                    Right(rt, value);
                    return(AddResult.State.OK);

                case "bottom":
                    Bottom(rt, value);
                    return(AddResult.State.OK);

                case "top":
                    Top(rt, value);
                    return(AddResult.State.OK);

                case "width":
                    Width(rt, value);
                    return(AddResult.State.OK);

                case "height":
                    Height(rt, value);
                    return(AddResult.State.OK);

                case "side":
                    Side(rt, value);
                    return(AddResult.State.OK);

                case "anchor":
                    Anchor(rt, value);
                    return(AddResult.State.OK);
                }
            }
            catch (Exception e)
            {
                return(new AddResult(AddResult.State.Error)
                {
                    message = e.Message
                });
            }
            return(AddResult.State.Ignored);
        }
Пример #6
0
 public IXMLElement AddElement(string name, XMLElementUI <TAppData, TModuleData, TElementData> previewElement)
 {
     if (previewElement.isRoot)
     {
         return(rootHandler.AddElement(name, previewElement));
     }
     else
     {
         return(elementHandler.AddElement(name, previewElement));
     }
 }
Пример #7
0
        public IXMLElement AddElement(string name, XMLElementUI <TAppData, TModuleData, TElementData> previewElement)
        {
            var m = GetMethod(previewElement.module.data.GetVersion());

            if (m != null)
            {
                return(m(name, previewElement));
            }

            throw new VersionException(this, previewElement.module.data.GetVersion());
        }
Пример #8
0
        public IXMLElement AddElement(string name, XMLElementUI <AppData, ModuleData, ElementData> previewElement)
        {
            var result = addElementHandler.AddElement(name, previewElement);
            var bomb   = result as BombElement;

            if (bomb != null)
            {
                bomb.message = "Ensure you added required using namespaces or folders. If you need an empty gameObject use \"void\" element";
                return(bomb);
            }
            return(result);
        }
Пример #9
0
        new public IXMLElement AddElement(string name, XMLElementUI <TAppData, TModuleData, TElementData> previewElement)
        {
            foreach (var h in handlers)
            {
                var result = h.AddElement(name, previewElement);
                if (!(result is FakeElement))
                {
                    return(result);
                }
            }

            return(new BombElement(name, previewElement.name));
        }
        new public IXMLElement AddElement(string name, XMLElementUI <TAppData, TModuleData, TElementData> previewElement)
        {
            var namespaces = previewElement.module.data.GetNamespaces();

            var componentType = ComponentGetter.GetFromAssemblies(name, namespaces);

            if (componentType != null)
            {
                GameObject go = new GameObject(name);
                go.AddComponent(componentType);
                return(previewElement.CreateElement(name, previewElement.data.CreateChild(go)));
            }

            return(new BombElement(name, previewElement.name));
        }
Пример #11
0
        new public IXMLElement AddElement(string name, XMLElementUI <TAppData, TModuleData, TElementData> previewElement)
        {
            UnityEngine.Object prefab = null;
            foreach (var folder in previewElement.module.data.GetResFolders())
            {
                prefab = Resources.Load(string.Join("/", new string[] { folder, name }));
                if (prefab != null)
                {
                    return(previewElement.CreateElement(name,
                                                        previewElement.data.CreateChild(GameObject.Instantiate((prefab as GameObject)))
                                                        ));
                }
            }

            return(new BombElement(name, previewElement.name));
        }
        new public IXMLElement AddElement(string name, XMLElementUI <TAppData, TModuleData, TElementData> previewElement)
        {
            switch (name)
            {
            case "controller":
                return(new ControllerState <TAppData, TModuleData, TElementData>(previewElement));

            case "component":
                return(new ComponentState <TAppData, TModuleData, TElementData>(previewElement));

            case "void":
                return(previewElement.CreateElement(name, previewElement.data.CreateChild(name)));

            default:
                return(new BombElement(name, previewElement.name));
            }
        }
Пример #13
0
        new public IXMLElement AddElement(string name, XMLElementUI <TAppData, TModuleData, TElementData> previewElement)
        {
            switch (name)
            {
            case "version":
                return(new VersionState <TAppData, TModuleData, TElementData>(previewElement));

            case "using":
                return(new UsingState <TAppData, TModuleData, TElementData>(previewElement));

            case "include":
                return(new IncludeState <TAppData, TModuleData, TElementData>(previewElement));

            case "define":
                return(new DefineState <TAppData, TModuleData, TElementData>(previewElement));

            default:
                return(new BombElement(name, previewElement.name));
            }
        }
Пример #14
0
 public IncludeState(XMLElementUI <TAppData, TModelData, TElementData> element) : this("include", element)
 {
 }
Пример #15
0
 public DefineState(XMLElementUI <TAppData, TModuleData, TElementData> element) : base("define", element)
 {
 }
Пример #16
0
 public UsingState(XMLElementUI <TAppData, TModelData, TElementData> element) : this("using", element)
 {
 }
Пример #17
0
 public ControllerState(XMLElementUI <TAppData, TModuleData, TElementData> element)
     : this("controller", element)
 {
 }
Пример #18
0
        new public AddResult AddAttribute(string attributeName, string attributeValue, XMLElementUI <TAppData, TModuleData, TElementData> element)
        {
            AddResult r = AddResult.State.Ignored;

            foreach (var h in handlers)
            {
                r |= h.AddAttribute(attributeName, attributeValue, element);
                if (!r.ignored)
                {
                    return(r);
                }
            }
            return(r);
        }
Пример #19
0
 public ComponentState(XMLElementUI <TAppData, TModuleData, TElementData> element)
     : base("component", element)
 {
 }
Пример #20
0
 public DefineHelper(string className, XMLElementUI <TAppData, TModuleData, TElementData> element) : base(className, element)
 {
 }
Пример #21
0
        new public AddResult AddAttribute(string attributeName, string attributeValue, XMLElementUI <TAppData, TModelData, TElementData> element)
        {
            switch (attributeName)
            {
            case class_st:
                foreach (var a in element.module.data.GetClassAttributes(attributeValue))
                {
                    element.AddAttribute(a.name, a.value);
                }
                return(AddResult.State.OK);

            case id_st:
                try {
                    element.module.data.AddIDObject(attributeValue, element.data.GetGameObject());
                }
                catch (Exception e) { return(new AddResult(AddResult.State.Error)
                    {
                        message = e.Message
                    }); }
                return(AddResult.State.OK);

            case call_st:
                var controller = element.data.GetController();
                var gameObject = element.data.GetGameObject();

                var m = controller.GetType().GetMethod(attributeValue, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public, null, new Type[] { typeof(GameObject) }, null);
                if (m != null)
                {
                    m.Invoke(controller, new object[] { gameObject });
                }
                else
                {
                    return new AddResult(AddResult.State.Error)
                           {
                               message = controller + " has no method " + attributeValue + "(GameObject sender)."
                           }
                };
                return(AddResult.State.OK);

            default:
                return(AddResult.State.Ignored);
            }
        }
Пример #22
0
 public ControllerState(string name, XMLElementUI <TAppData, TModuleData, TElementData> element)
 // creating new element with clone preview element data to keep preview controller unaltered
     : base(name, new XMLElementUI <TAppData, TModuleData, TElementData>(element.name, element.data.Clone(), element.module))
 {
 }
Пример #23
0
 public State(string name, XMLElementUI <TAppData, TModelData, TElementData> element)
 {
     this.name = name; this.element = element;
 }
Пример #24
0
 public UsingState(string name, XMLElementUI <TAppData, TModelData, TElementData> element) : base(name, element)
 {
 }
Пример #25
0
 public VersionState(XMLElementUI <TAppData, TModuleData, TElementData> element)
     : base("version", element)
 {
 }