public void ProcessModel(IKernel kernel, ComponentModel model)
		{
			if (model.Configuration == null) return;

			var mixins = model.Configuration.Children["mixins"];
			if (mixins == null) return;

			var options = ProxyUtil.ObtainProxyOptions(model, true);
			foreach (var mixin in mixins.Children)
			{
				var value = mixin.Value;

				if (!ReferenceExpressionUtil.IsReference(value))
				{
					throw new Exception(
						String.Format("The value for the mixin must be a reference to a component (Currently {0})", value));
				}

				var componentKey = ReferenceExpressionUtil.ExtractComponentKey(value);
				var mixIn = new ComponentReference<object>(componentKey);
				options.AddMixinReference(mixIn);
				model.Dependencies.Add(CreateDependencyModel(componentKey));
			}

		}
    protected virtual void OnEnable()
    {
        if (viewStateL == null)
        {
            viewStateL = new TreeViewState();
        }
        if (viewStateR == null)
        {
            viewStateR = new TreeViewState();
        }
        //todo
        var dic = new Dictionary <Type, bool>();

        if (oneToMany)
        {
            dic.Add(typeof(R), true);
        }

        linktionary = new ConnetionLinkDictionary <Type, Component>(typeof(T), typeof(R), dic);
        selected    = new ComponentReference();
        inspector   = new GuillaumeInspector()
        {
            selected = selected
        };
        interactionTreeList  = new InteractionTreeView <T>(inspector, viewStateL, false, ref linktionary);
        interactionTreeListR = new InteractionTreeView <R>(inspector, viewStateR, true, ref linktionary);
    }
 public void OnGUI(Rect rect, ComponentReference select)
 {
     if (selected?.serialized != null)
     {
         EditorGUIUtility.DrawColorSwatch(rect, new Color(0.1f, 0.1f, 0.1f, 0.5f));
         DrawProperties(selected.serialized, rect);
     }
 }
        private void OnValidate()
        {
            if (container == null)
            {
                container = new();
            }

            container.Component = GetComponent <Container>();
        }
 public ActionResult <JsonResponse> DeleteSiteComponentMethod(ComponentReference Component, int admin_id, string admin_token, int site_id)
 {
     if (authenticator.VerifyAdminForLeaf(admin_id, site_id, admin_token))
     {
         return(DeleteAuthenticatedSiteComponentMethod(Component));
     }
     else
     {
         return(StatusCode(400, "Invalid credentials."));
     }
 }
Beispiel #6
0
 public void RemoveAllComponents()
 {
     Type[] oldComponents = GetAllComponents();
     foreach (Type component in components.Keys)
     {
         int index = components[component];
         ComponentReference componentReference = new ComponentReference()
         {
             index         = index,
             ComponentType = component
         };
         componentManager.Remove(componentReference);
     }
 }
Beispiel #7
0
        public T GetComponent <T>() where T : Component
        {
            T    component = (T)Activator.CreateInstance(typeof(T));
            Type t         = component.GetType();

            if (!components.ContainsKey(t))
            {
                return(null);
            }

            ComponentReference cr = new ComponentReference()
            {
                index         = components[t],
                ComponentType = t
            };

            return(componentManager.Get(cr) as T);
        }
Beispiel #8
0
        /// <summary>
        /// Draw the actual property.
        /// </summary>
        public override void OnGUI(Rect rect, SerializedProperty prop, GUIContent label)
        {
            SerializedProperty target = prop.FindPropertyRelative("mTarget");
            SerializedProperty field  = prop.FindPropertyRelative("mName");

            rect.height = 16f;
            EditorGUI.PropertyField(rect, target, label);

            Component comp = target.objectReferenceValue as Component;

            if (comp != null)
            {
                rect.y     += 18f;
                GUI.changed = false;
                EditorGUI.BeginDisabledGroup(target.hasMultipleDifferentValues);
                int index = 0;

                // Get all the properties on the target game object
                List <ComponentReference> list = GetProperties(comp.gameObject, mustRead, mustWrite);

                // We want the field to look like "Component.property" rather than just "property"
                string current =
                    PropertyBindingReference.ToString(target.objectReferenceValue as Component, field.stringValue);

                // Convert all the properties to names
                string[] names = GetNames(list, current, out index);

                // Draw a selection list
                GUI.changed = false;
                rect.xMin  += EditorGUIUtility.labelWidth;
                rect.width -= 18f;
                int choice = EditorGUI.Popup(rect, "", index, names);

                // Update the target object and property name
                if (GUI.changed && choice > 0)
                {
                    ComponentReference ent = list[choice - 1];
                    target.objectReferenceValue = ent.target;
                    field.stringValue           = ent.name;
                }

                EditorGUI.EndDisabledGroup();
            }
        }
Beispiel #9
0
        /// <summary>
        /// Convert the specified list of delegate entries into a string array.
        /// </summary>
        public static string[] GetNames(List <ComponentReference> list, string choice, out int index)
        {
            index = 0;
            string[] names = new string[list.Count + 1];
            names[0] = string.IsNullOrEmpty(choice) ? "<Choose>" : choice;

            for (int i = 0; i < list.Count;)
            {
                ComponentReference ent = list[i];
                string             del = ActionDelegateEditor.GetFuncName(ent.target, ent.name);
                names[++i] = del;
                if (index == 0 && string.Equals(del, choice))
                {
                    index = i;
                }
            }

            return(names);
        }
        public ActionResult <JsonResponse> DeleteSite(int site_id, int admin_id, string admin_token)
        {
            if (authenticator.VerifyAdminForLeaf(admin_id, site_id, admin_token))
            {
                SkeletonSiteDto found_site = dbQuery.QuerySkeletonSiteById(site_id);

                //must be done manually by the app to properly update the data limiter
                foreach (SiteComponentDto site_component in found_site.site_components)
                {
                    ComponentReference component_reference = new ComponentReference()
                    {
                        component_id   = site_component.component_id,
                        component_type = site_component.type
                    };
                    DeleteAuthenticatedSiteComponentMethod(component_reference);
                }

                //manually remove nav link data from data plan
                List <NavLink> found_nav_links;
                try{
                    found_nav_links = dbQuery.QueryNavBarLinksBySiteId(site_id);
                }catch {
                    found_nav_links = null;
                }
                if (found_nav_links != null)
                {
                    foreach (NavLink nav_link in found_nav_links)
                    {
                        _dataLimiter.RemoveNavLinkFromDataPlan(nav_link, admin_id);
                    }
                }

                _dataLimiter.RemoveSiteFromDataPlan(admin_id);
                Site         DeletedSite = dbQuery.DeleteSiteById(site_id);
                JsonResponse r           = new JsonSuccess($"Site {DeletedSite.title} deleted sucessfully!");
                return(r);
            }
            else
            {
                return(StatusCode(400, "Invalid Token. Stranger Danger."));
            }
        }
Beispiel #11
0
        public static bool AssignComponent(ComponentBoardBase componentBoard, ComponentReference componentReference, EntityBoardContainer entityBoard, GameEntityHandle entityHandle)
        {
            componentBoard.AddReference(componentReference.Id, entityHandle);

            var previousComponentId = entityBoard.AssignComponentReference(entityHandle.Id, componentReference.Type.Id, componentReference.Id);

            if (previousComponentId > 0)
            {
                var refs = componentBoard.RemoveReference(previousComponentId, entityHandle);

                // nobody reference this component anymore, let's remove the row
                if (refs == 0)
                {
                    componentBoard.DeleteRow(previousComponentId);
                }

                return(false);
            }

            return(true);
        }
Beispiel #12
0
 public static Span <GameEntityHandle> GetReferences(ComponentBoardBase componentBoard, ComponentReference componentReference)
 {
     return(componentBoard.GetReferences(componentReference.Id));
 }
Beispiel #13
0
 public static GameEntityHandle GetOwner(ComponentBoardBase componentBoard, ComponentReference componentReference)
 {
     return(componentBoard.OwnerColumn[(int)componentReference.Id]);
 }
Beispiel #14
0
 public static void SetOwner(ComponentBoardBase componentBoard, ComponentReference componentReference, GameEntityHandle entityHandle)
 {
     componentBoard.OwnerColumn[(int)componentReference.Id] = entityHandle;
 }
 public ActionResult <JsonResponse> DeleteAuthenticatedSiteComponentMethod(ComponentReference Component)
 {
     if (Component.component_type == "p_box")
     {
         try{
             ParagraphBox paragraph_box = dbQuery.DeleteParagraphBox(Component.component_id);
             Site         parent_site   = dbQuery.QueryFeaturelessSiteById(paragraph_box.site_id);
             _dataLimiter.RemoveFromDataPlan(paragraph_box, parent_site.admin_id);
             JsonResponse r = new JsonSuccess("Paragraph box deleted sucessfully!");
             return(r);
         }catch {
             JsonFailure f = new JsonFailure($"Unable to find paragraph box id {Component.component_id}");
             return(StatusCode(400, f));
         }
     }
     else if (Component.component_type == "image")
     {
         try{
             Image image       = dbQuery.DeleteImage(Component.component_id);
             Site  parent_site = dbQuery.QueryFeaturelessSiteById(image.site_id);
             _dataLimiter.RemoveFromDataPlan(image, parent_site.admin_id);
             JsonResponse r = new JsonSuccess("Image deleted sucessfully!");
             return(r);
         }catch {
             JsonFailure f = new JsonFailure($"Unable to find image id {Component.component_id}");
             return(StatusCode(400, f));
         }
     }
     else if (Component.component_type == "portrait")
     {
         try{
             Portrait portrait    = dbQuery.DeletePortrait(Component.component_id);
             Site     parent_site = dbQuery.QueryFeaturelessSiteById(portrait.site_id);
             _dataLimiter.RemoveFromDataPlan(portrait, parent_site.admin_id);
             JsonResponse r = new JsonSuccess("Portrait component deleted sucessfully!");
             return(r);
         }catch {
             JsonFailure f = new JsonFailure($"Unable to find portrait id {Component.component_id}");
             return(StatusCode(400, f));
         }
     }
     else if (Component.component_type == "2c_box")
     {
         try{
             TwoColumnBox two_column_box = dbQuery.DeleteTwoColumnBox(Component.component_id);
             Site         parent_site    = dbQuery.QueryFeaturelessSiteById(two_column_box.site_id);
             _dataLimiter.RemoveFromDataPlan(two_column_box, parent_site.admin_id);
             JsonResponse r = new JsonSuccess("Two Column Box component deleted sucessfully!");
             return(r);
         }catch {
             JsonFailure f = new JsonFailure($"Unable to find two column box id {Component.component_id}");
             return(StatusCode(400, f));
         }
     }
     else if (Component.component_type == "link_box")
     {
         try{
             LinkBox link_box    = dbQuery.DeleteLinkBox(Component.component_id);
             Site    parent_site = dbQuery.QueryFeaturelessSiteById(link_box.site_id);
             _dataLimiter.RemoveFromDataPlan(link_box, parent_site.admin_id);
             JsonResponse r = new JsonSuccess("Link Box component deleted sucessfully!");
             return(r);
         }catch {
             JsonFailure f = new JsonFailure($"Unable to find link box id {Component.component_id}");
             return(StatusCode(400, f));
         }
     }
     else
     {
         JsonFailure f = new JsonFailure("Type mismatch. Type does not match any known components.");
         return(StatusCode(400, f));
     }
 }
Beispiel #16
0
 public ActionResult <JsonResponse> DeleteSiteComponent([FromBody] ComponentReference Component, int admin_id, string admin_token, int site_id)
 {
     return(methods.DeleteSiteComponentMethod(Component, admin_id, admin_token, site_id));
 }
Beispiel #17
0
        /// <summary>
        /// Collect a list of usable properties and fields.
        /// </summary>
        public static List <ComponentReference> GetProperties(GameObject target, bool read, bool write)
        {
            Component[] comps = target.GetComponents <Component>();

            List <ComponentReference> list = new List <ComponentReference>();

            for (int i = 0, imax = comps.Length; i < imax; ++i)
            {
                Component comp = comps[i];
                if (comp == null)
                {
                    continue;
                }

                Type           type   = comp.GetType();
                BindingFlags   flags  = BindingFlags.Instance | BindingFlags.Public;
                FieldInfo[]    fields = type.GetFields(flags);
                PropertyInfo[] props  = type.GetProperties(flags);

                // The component itself without any method
                if (PropertyBindingReference.Convert(comp, filter))
                {
                    ComponentReference ent = new ComponentReference();
                    ent.target = comp;
                    list.Add(ent);
                }

                for (int b = 0; b < fields.Length; ++b)
                {
                    FieldInfo field = fields[b];

                    if (filter != typeof(void))
                    {
                        if (canConvert)
                        {
                            if (!PropertyBindingReference.Convert(field.FieldType, filter))
                            {
                                continue;
                            }
                        }
                        else if (!filter.IsAssignableFrom(field.FieldType))
                        {
                            continue;
                        }
                    }

                    ComponentReference ent = new ComponentReference();
                    ent.target = comp;
                    ent.name   = field.Name;
                    list.Add(ent);
                }

                for (int b = 0; b < props.Length; ++b)
                {
                    PropertyInfo prop = props[b];
                    if (read && !prop.CanRead)
                    {
                        continue;
                    }

                    if (write && !prop.CanWrite)
                    {
                        continue;
                    }

                    if (filter != typeof(void))
                    {
                        if (canConvert)
                        {
                            if (!PropertyBindingReference.Convert(prop.PropertyType, filter))
                            {
                                continue;
                            }
                        }
                        else if (!filter.IsAssignableFrom(prop.PropertyType))
                        {
                            continue;
                        }
                    }

                    ComponentReference ent = new ComponentReference();
                    ent.target = comp;
                    ent.name   = prop.Name;
                    list.Add(ent);
                }
            }

            return(list);
        }