Пример #1
0
        public static Component Create(ComponentIdentifier identifier, Dictionary <string, object> data)
        {
            Component newComponent = new Component(identifier.Description);

            // Apply configuration
            if (identifier.Configuration != null)
            {
                foreach (var setter in identifier.Configuration.Setters)
                {
                    if (!data.ContainsKey(setter.Key))
                    {
                        data.Add(setter.Key, setter.Value);
                    }
                    else
                    {
                        data[setter.Key] = setter.Value;
                    }
                }
            }

            // Load other properties
            newComponent.Deserialize(data);

            newComponent.ResetConnections();

            if (newComponent.Editor != null)
            {
                newComponent.Editor.Update();
            }

            return(newComponent);
        }
Пример #2
0
        public static Component Create(string data)
        {
            // Load data
            data = data.Replace(",", "\r\n");
            Dictionary <string, object> properties = ComponentDataString.ConvertToDictionary(data);

            // Find component description
            ComponentDescription description;

            if (properties.ContainsKey("@rid"))
            {
                description = ComponentHelper.FindDescriptionByRuntimeID(int.Parse(properties["@rid"].ToString()));
            }
            else if (properties.ContainsKey("@guid"))
            {
                description = ComponentHelper.FindDescription(new Guid(properties["@guid"].ToString()));
            }
            else
            {
                description = ComponentHelper.FindDescription(properties["@type"].ToString());
            }
            Component newComponent = new Component(description);

            // Apply configuration
            if (properties.ContainsKey("@config"))
            {
                ComponentConfiguration configuration = description.Metadata.Configurations.FirstOrDefault(item => item.Name == properties["@config"].ToString());
                if (configuration != null)
                {
                    foreach (var setter in configuration.Setters)
                    {
                        if (!properties.ContainsKey(setter.Key))
                        {
                            properties.Add(setter.Key, setter.Value);
                        }
                        else
                        {
                            properties[setter.Key] = setter.Value;
                        }
                    }
                }
            }

            // Load other properties
            newComponent.Deserialize(properties);

            newComponent.ResetConnections();

            if (newComponent.Editor != null)
            {
                newComponent.Editor.Update();
            }

            return(newComponent);
        }
Пример #3
0
        public static Component Create(ComponentDescription description, Dictionary <string, object> data)
        {
            Component newComponent = new Component(description);

            // Load other properties
            newComponent.Deserialize(data);

            newComponent.ResetConnections();

            if (newComponent.Editor != null)
            {
                newComponent.Editor.Update();
            }

            return(newComponent);
        }
Пример #4
0
        public static Component Create(string data)
        {
            // Load data
            data = data.Replace(",", "\r\n");
            Dictionary<string, object> properties = ComponentDataString.ConvertToDictionary(data);

            // Find component description
            ComponentDescription description;
            if (properties.ContainsKey("@rid"))
                description = ComponentHelper.FindDescriptionByRuntimeID(int.Parse(properties["@rid"].ToString()));
            else if (properties.ContainsKey("@guid"))
                description = ComponentHelper.FindDescription(new Guid(properties["@guid"].ToString()));
            else
                description = ComponentHelper.FindDescription(properties["@type"].ToString());
            Component newComponent = new Component(description);

            // Apply configuration
            if (properties.ContainsKey("@config"))
            {
                ComponentConfiguration configuration = description.Metadata.Configurations.FirstOrDefault(item => item.Name == properties["@config"].ToString());
                if (configuration != null)
                {
                    foreach (var setter in configuration.Setters)
                    {
                        if (!properties.ContainsKey(setter.Key))
                            properties.Add(setter.Key, setter.Value);
                        else
                            properties[setter.Key] = setter.Value;
                    }
                }
            }

            // Load other properties
            newComponent.Deserialize(properties);

            newComponent.ResetConnections();

            if (newComponent.Editor != null)
                newComponent.Editor.Update();

            return newComponent;
        }
Пример #5
0
        public static Component Create(ComponentIdentifier identifier, Dictionary<string, object> data)
        {
            Component newComponent = new Component(identifier.Description);

            // Apply configuration
            if (identifier.Configuration != null)
            {
                foreach (var setter in identifier.Configuration.Setters)
                {
                    if (!data.ContainsKey(setter.Key))
                        data.Add(setter.Key, setter.Value);
                    else
                        data[setter.Key] = setter.Value;
                }
            }

            // Load other properties
            newComponent.Deserialize(data);

            newComponent.ResetConnections();

            if (newComponent.Editor != null)
                newComponent.Editor.Update();

            return newComponent;
        }
Пример #6
0
        public static Component Create(ComponentDescription description, Dictionary<string, object> data)
        {
            Component newComponent = new Component(description);

            // Load other properties
            newComponent.Deserialize(data);

            newComponent.ResetConnections();

            if (newComponent.Editor != null)
                newComponent.Editor.Update();

            return newComponent;
        }