protected override void Send(ILogger logger,
                                     Notification notification,
                                     AccountDbContext accountDbContext,
                                     string accountName, Guid accountId)
        {
            var to = notification.Address;
            var componentRepository = accountDbContext.GetComponentRepository();
            var component           = componentRepository.GetById(notification.Event.OwnerId);
            var path = ComponentHelper.GetComponentPathText(component);

            var subject = string.Format("{0} - {1}", path, GetEventImportanceText(notification.Event.Importance));

            if (notification.Reason == NotificationReason.Reminder)
            {
                subject = subject + " (напоминание)";
            }

            // составляем тело письма
            var user     = accountDbContext.GetUserRepository().GetById(notification.UserId);
            var htmlBody = GetStatusEventHtml(user, logger, notification, component, accountDbContext, accountName);

            // сохраняем письмо в очередь
            var emailRepository = accountDbContext.GetSendEmailCommandRepository();
            var command         = new SendEmailCommand()
            {
                Id          = Guid.NewGuid(),
                Body        = htmlBody,
                IsHtml      = true,
                Subject     = subject,
                To          = to,
                ReferenceId = notification.Id
            };

            emailRepository.Add(command);
        }
示例#2
0
        public override int GetHashCode()
        {
            unchecked
            {
                var hash = 13;
                hash = (hash * 397) ^ Type.GetHashCode();

                switch (Type)
                {
                case VariableType.Boolean: hash = (hash * 397) ^ Boolean.GetHashCode(); break;

                case VariableType.Integer: hash = (hash * 397) ^ Integer.GetHashCode(); break;

                case VariableType.Number: hash = (hash * 397) ^ Number.GetHashCode(); break;

                case VariableType.String: hash = (hash * 397) ^ String.GetHashCode(); break;

                case VariableType.Object: hash = (hash * 397) ^ ComponentHelper.GetAsBaseObject(Object).GetHashCode(); break;

                case VariableType.Store: hash = (hash * 397) ^ Store.GetHashCode(); break;
                }

                return(hash);
            }
        }
示例#3
0
        private Widget CreatePageTab(WorkBookPage child)
        {
            HBox hb = new HBox {
                Spacing = 0
            };

            Label lbl = new Label {
                Markup = new PangoStyle {
                    Size = PangoStyle.TextSize.Small, Text = child.PageTitle
                }
            };

            hb.PackStart(lbl, false, true, 0);

            Button btn = new Button {
                Relief = ReliefStyle.None, FocusOnClick = false
            };

            btn.Add(ComponentHelper.LoadImage("Warehouse.Component.WorkBook.Icon.Close12.png"));
            btn.Clicked += CloseButton_Clicked;
            hb.PackEnd(btn, false, true, 0);

            hb.ShowAll();
            return(hb);
        }
        public JsonResult GetTableColumn()
        {
            string id        = Request.Form[NamingCenter.PARAM_PARENT_ID];
            string pageId    = Request.Form[NamingCenter.PARAM_PAGE_ID];
            var    component = PageBuilder.BuildPage(pageId).FindControl(id);

            if (component is FoxOne.Controls.Table)
            {
                var table = component as FoxOne.Controls.Table;
                if (table.DataSource == null)
                {
                    throw new FoxOneException("Need_DataSource", table.Id);
                }
                var data = table.GetData();
                if (data.IsNullOrEmpty())
                {
                    throw new FoxOneException("DataSource_Return_Empty", table.Id);
                }
                table.GenerateTableColumn(data);
                foreach (var column in table.Columns)
                {
                    column.PageId   = pageId;
                    column.ParentId = id;
                    column.TargetId = "Columns";
                    ComponentHelper.RecSave(column);
                }
                return(Json(true));
            }
            throw new FoxOneException("Only_Suppost_Table_Ctrl");
        }
示例#5
0
        void context_PostRequestHandlerExecute(object sender, EventArgs e)
        {
            HttpContext   context = HttpContext.Current;
            UploadSession session = SlickUploadContext.CurrentUploadSessionInternal;

            if (session != null && session.State != UploadState.Uploading)
            {
                SlickUploadContext.CommitSession(session);
            }

            ComponentHelper.EnsureScriptsRendered();

            // We're set to use session state, but we didn't create a cookie. Ensure we do.
            if (HttpContext.Current.Items["EnsureSessionCreated"] != null)
            {
                HttpCookie cookie = context.Response.Cookies[_sessionCookieName];

                if (cookie == null)
                {
                    cookie = new HttpCookie(_sessionCookieName, context.Session.SessionID)
                    {
                        Path = "/", HttpOnly = true
                    }
                }
                ;
                else
                {
                    cookie.Value = context.Session.SessionID;
                }

                context.Items["SlickUploadSessionStateFixCookie"] = cookie;
            }
        }
示例#6
0
        private void btnImplementationsNew_Click(object sender, RoutedEventArgs e)
        {
            winNewComponentImplementation newComImplementation = new winNewComponentImplementation();

            newComImplementation.Owner             = this;
            newComImplementation.ImplementationSet = cbxImplementationsSet.Text;
            if (newComImplementation.ShowDialog() == true)
            {
                if (cbxImplementationsSet.SelectedItem == null)
                {
                    ComponentRepresentations.Add(new ImplementationConversionCollection()
                    {
                        ImplementationSet = cbxImplementationsSet.Text
                    });
                    cbxImplementationsSet.SelectedItem = ComponentRepresentations.Last();
                }

                ImplementationConversion conversion = newComImplementation.GetChosenComponent();

                // Don't allow duplicates
                if ((cbxImplementationsSet.SelectedItem as ImplementationConversionCollection).Items.FirstOrDefault(item => item.ImplementationName == conversion.ImplementationName) != null)
                {
                    TaskDialogInterop.TaskDialog.ShowMessage(this, "The item could not be added because it is already present.\r\n\r\nYou can add this item again if you delete its current representation first.", "Could Not Add Item", TaskDialogInterop.TaskDialogCommonButtons.Close, TaskDialogInterop.VistaTaskDialogIcon.Warning);
                }
                else
                {
                    (cbxImplementationsSet.SelectedItem as ImplementationConversionCollection).Items.Add(newComImplementation.GetChosenComponent());

                    // Add to ComponentHelper's list of conversions
                    ComponentDescription   description      = ComponentHelper.FindDescription(conversion.ToGUID);
                    ComponentConfiguration theConfiguration = description.Metadata.Configurations.FirstOrDefault(check => check.Name == conversion.ToConfiguration);
                    ComponentHelper.SetStandardComponent(cbxImplementationsSet.Text, conversion.ImplementationName, description, theConfiguration);
                }
            }
        }
示例#7
0
        /// <summary>
        /// Adds a component to the entity.
        /// </summary>
        /// <param name="type">The type of the component.</param>
        /// <returns>
        /// The component instance.
        /// </returns>
        /// <exception cref="System.Exception">Component already exists.</exception>
        internal Component AddComponent(Type type)
        {
            var info = ComponentHelper.GetInfo(type);
            if (!info.HasValue)
            {
                throw new Exception("Internal error: component is not registered.");
            }

            ulong id = info.Value.Id;

            if (this.components[id] != null)
            {
                throw new Exception("Component already exists.");
            }

            var component = ComponentHelper.CreateInstance(type);
            component.Owner = this;

            this.components[id] = component;

            var drawable = component as DrawableComponent;
            if (drawable != null)
            {
                this.drawableComponents[id] = drawable;
            }

            this.ComponentMask |= info.Value.Mask;

            return component;
        }
示例#8
0
        public override void OnInspectorGUI()
        {
            using (new UndoScope(serializedObject))
            {
                EditorGUILayout.Space();
                EditorGUILayout.PropertyField(_begin);
                EditorGUILayout.PropertyField(_path);
            }

            if (_pathController.Path.UsePathfinding)
            {
                using (new EditorGUILayout.HorizontalScope())
                {
                    var pathfinding = ComponentHelper.GetComponentInScene <Pathfinding>(_pathController.gameObject.scene.buildIndex, false);
                    if (pathfinding == null)
                    {
                        EditorGUILayout.HelpBox("In order to use pathfinding this scene's map object must have a pathfinding component attached", MessageType.Warning, true);

                        if (GUILayout.Button(_createPathfindingContent, GUILayout.Height(39)))
                        {
                            var properties = ComponentHelper.GetComponentInScene <MapProperties>(_pathController.gameObject.scene.buildIndex, false);
                            if (properties)
                            {
                                var path = Undo.AddComponent <Pathfinding>(properties.gameObject);
                                path.RegenerateNodes();
                            }
                        }
                    }
                }
            }
        }
示例#9
0
        public virtual ResponseType Run()
        {
            try {
                DialogControl.Shown       -= OnShown;
                DialogControl.Shown       += OnShown;
                DialogControl.Hidden      -= DialogControl_Hidden;
                DialogControl.Hidden      += DialogControl_Hidden;
                DialogControl.DeleteEvent += DialogControl_DeleteEvent;
                if (hidden)
                {
                    PushModalDialog();
                }

                ResponseType ret = (ResponseType)DialogControl.Run();
                Hide();

                return(ret);

#if !DEBUG
            } catch {
                ComponentHelper.PopModal(DialogControl);
                Hide();
                throw;
#endif
            } finally {
                DialogControl.DeleteEvent -= DialogControl_DeleteEvent;
                DialogControl.Hidden      -= DialogControl_Hidden;
                DialogControl.Shown       -= OnShown;
            }
        }
示例#10
0
        internal bool Loaded()
        {
            var objects = Zone.Scene.Scene.GetRootGameObjects();

            foreach (var obj in objects)
            {
                if (Properties = obj.GetComponent <MapProperties>())
                {
                    break;
                }
            }

            if (Properties != null)
            {
                ComponentHelper.GetComponentsInScene(Zone.Scene.Index, Npcs, true);
                Pathfinding = Properties.GetComponent <Pathfinding>();
                Properties.AddConnections(Connections);
                Properties.AddSpawnPoints(SpawnPoints);

                return(true);
            }
            else
            {
                Debug.LogErrorFormat(_missingMapPropertiesError, Zone.name);
                return(false);
            }
        }
示例#11
0
        public T Add <T>() where T : Component
        {
            ComponentHelper.Assert <T>();

            /*if (!ComponentHelper.AllowMultiple<T>() && Handle.Has<T>()) {
             *  throw new Exception($"Already has a component of type {typeof(T).Name}");
             * }
             * T component = Activator.CreateInstance<T>();
             * component.AppendTo(this);
             * Events.RaiseAddedComponent(component);
             * var registerAs = ComponentHelper.GetRegisterAs<T>();
             * if (registerAs != null) {
             *  registerAs.CallSet(Handle, component);
             * } else {
             *  Handle.Set(component);
             * }
             * return component;*/

            T component = Activator.CreateInstance <T>();

            ComponentHelper.CallSet(Handle, component);
            component.AppendTo(this);
            Events.RaiseAddedComponent(component);
            return(component);
        }
        public static void InitializeState()
        {
            ViewComponent.GridLoginCustomer.Margin = MarginPosition.Middle;
            ViewComponent.GridLoginCustomer.Width  = 376.8;
            ViewComponent.GridLoginCustomer.Height = 413;
            ComponentHelper.changeVisibilityComponent(ViewComponent.GridLoginCustomer, Visibility.Visible);

            ViewComponent.GridRegisterCustomer1.Margin  = MarginPosition.Right;
            ViewComponent.GridRegisterCustomer1.Opacity = 0;
            ViewComponent.GridRegisterCustomer1.Width   = 376.8;
            ViewComponent.GridRegisterCustomer1.Height  = 413;
            ComponentHelper.changeVisibilityComponent(ViewComponent.GridRegisterCustomer1, Visibility.Hidden);

            ViewComponent.GridRegisterCustomer2.Margin  = MarginPosition.Right;
            ViewComponent.GridRegisterCustomer2.Opacity = 0;
            ViewComponent.GridRegisterCustomer2.Width   = 376.8;
            ViewComponent.GridRegisterCustomer2.Height  = 413;
            ComponentHelper.changeVisibilityComponent(ViewComponent.GridRegisterCustomer2, Visibility.Hidden);

            ViewComponent.GridRegisterCustomer3.Margin  = MarginPosition.Right;
            ViewComponent.GridRegisterCustomer3.Opacity = 0;
            ViewComponent.GridRegisterCustomer3.Width   = 376.8;
            ViewComponent.GridRegisterCustomer3.Height  = 413;
            ComponentHelper.changeVisibilityComponent(ViewComponent.GridRegisterCustomer3, Visibility.Hidden);
        }
示例#13
0
 /// <inheritdoc />
 /// <summary>
 /// Overridden. <inherited />
 /// </summary>
 protected override void OnInit(EventArgs e)
 {
     if (!typeof(MarkerControlBase).IsAssignableFrom(this.GetType()))
     {
         ComponentHelper.AddToRegistry(this);
     }
 }
        public JsonResult BatchAddActivity(string activitieNames, string definitionId)
        {
            bool result = false;
            var  activities = activitieNames.Split(',');
            int  top = 100, left = 100;

            foreach (var acti in activities)
            {
                var instance = new ResponseActivity();
                instance.PageId     = definitionId;
                instance.TargetId   = "Activity";
                instance.ParentId   = definitionId;
                instance.Id         = GetDefinitionNewId(definitionId);
                instance.Top        = top;
                instance.Left       = left;
                instance.Name       = instance.Id;
                instance.Alias      = typeof(ResponseActivity).GetDisplayName();
                instance.NeedChoice = true;
                if (instance.Id.EndsWith("1"))
                {
                    (instance as ResponseActivity).IsRoot = true;
                }
                instance.Actor = new FlowActor()
                {
                    FlowUser = FlowActorType.Creator
                };
                ComponentHelper.RecSave(instance);
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        private void QuitButton_Click(object sender, EventArgs e)
        {
            this.Hide();

            // create desktop shortcut
            if (DesktopShortcutCheckBox.Checked)
            {
                CreateShortcut(Path.Combine(
                                   Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
                                   "Project64 HD.lnk")
                               );
            }

            // create start menu shortcut
            if (StartMenuShortcutCheckBox.Checked)
            {
                CreateShortcut(Path.Combine(
                                   Environment.GetFolderPath(Environment.SpecialFolder.StartMenu),
                                   "Project64 HD.lnk")
                               );
            }

            if (TemporaryFilesCheckBox.Checked)
            {
                ComponentHelper.CleanupDownloadFiles(InstallerSettings.InstallerComponents);
            }

            Application.Exit();
        }
示例#16
0
        private void AddSearch()
        {
            if (Table == null)
            {
                return;
            }
            var search = new Search()
            {
                Rank = 2, Id = "{0}Search".FormatTo(ListPageName), PageId = ListPageName, ParentId = ListPageName, TargetId = "Right", TargetControlId = tableListTemplate.FormatTo(ListPageName)
            };

            foreach (var field in Table.Columns.Where(o => o.Searchable).OrderBy(o => o.Rank))
            {
                var f = ControlDefaultSetting.GetFormControl(field);
                f.Id       = field.Name;
                f.Name     = field.Name;
                f.Label    = field.Comment;
                f.Rank     = field.Rank;
                f.Enable   = true;
                f.Visiable = true;
                search.Fields.Add(f);
            }
            foreach (var btn in ControlDefaultSetting.GetDefaultSearchButton())
            {
                search.Buttons.Add(btn);
            }
            ComponentHelper.RecSave(search);
        }
示例#17
0
        public static void PushModalDialog(Window window, string windowId)
        {
            window.PushModal();
            if (string.IsNullOrEmpty(windowId))
            {
                return;
            }

            WindowSettings settings = WindowSettings.GetByWindowId(windowId);

            if (settings == null)
            {
                return;
            }

            window.Resize(settings.Width, settings.Height);
            foreach (Paned pane in ComponentHelper.GetChildWidgetsByType <Paned> (window))
            {
                PaneSettings pair = settings.Panes.FirstOrDefault(p => p.Name == pane.Name);
                if (pair != null)
                {
                    pane.Position = pair.Position;
                }
            }

            ColumnSerializer.LoadColumnSettings(window, settings);
        }
示例#18
0
        public void TestI_Q_KMeansInnerAPIWithDataFrame()
        {
            var methodName       = System.Reflection.MethodBase.GetCurrentMethod().Name;
            var outModelFilePath = FileHelper.GetOutputFile("outModelFilePath.zip", methodName);
            var iris             = FileHelper.GetTestFile("iris.txt");

            using (var env = new ConsoleEnvironment(conc: 1))
            {
                ComponentHelper.AddStandardComponents(env);

                var        df      = Scikit.ML.DataManipulation.DataFrameIO.ReadCsv(iris, sep: '\t', dtypes: new ColumnType[] { NumberType.R4 });
                var        conc    = env.CreateTransform("Concat{col=Feature:Sepal_length,Sepal_width}", df);
                var        roleMap = env.CreateExamples(conc, "Feature", label: "Label");
                var        trainer = CreateTrainer(env, "km");
                IPredictor model;
                using (var ch = env.Start("test"))
                    model = TrainUtils.Train(env, ch, roleMap, trainer, null, 0);

                using (var ch = env.Start("Save"))
                    using (var fs = File.Create(outModelFilePath))
                        TrainUtils.SaveModel(env, ch, fs, model, roleMap);

                Predictor pred;
                using (var fs = File.OpenRead(outModelFilePath))
                    pred = env.LoadPredictorOrNull(fs);

#pragma warning disable CS0618
                var scorer = ScoreUtils.GetScorer(pred.GetPredictorObject() as IPredictor, roleMap, env, null);
#pragma warning restore CS0618
                var dfout = Scikit.ML.DataManipulation.DataFrameIO.ReadView(scorer);
                Assert.AreEqual(dfout.Shape, new Tuple <int, int>(150, 13));
            }
        }
示例#19
0
        public ComponentStocks ConfirmOrder(ComponentUpdate componentUpdate)
        {
            ComponentHelper componentHelper = new ComponentHelper();

            using (var ctx = new CoffeShopContext())
            {
                List <Component> componentList = ctx.Components.ToList();
                var componentStocks            = componentHelper.CalculateNewStocks(componentUpdate, componentList);

                for (int i = 0; i < componentList.Count; i++)
                {
                    if (componentList[i].ComponentName == "Milk")
                    {
                        componentList[i].Stock = componentStocks.MilkInStock;
                    }
                    else if (componentList[i].ComponentName == "Coffe")
                    {
                        componentList[i].Stock = componentStocks.CoffeInStock;
                    }
                    else if (componentList[i].ComponentName == "Water")
                    {
                        componentList[i].Stock = componentStocks.WaterInStock;
                    }
                }

                ctx.SaveChanges();
                return(componentStocks);
            }
        }
示例#20
0
        public void TestScikitAPI_DelegateEnvironment()
        {
            var inputs = new[] {
                new ExampleA()
                {
                    X = new float[] { 1, 10, 100 }
                },
                new ExampleA()
                {
                    X = new float[] { 2, 3, 5 }
                }
            };

            var inputs2 = new[] {
                new ExampleA()
                {
                    X = new float[] { -1, -10, -100 }
                },
                new ExampleA()
                {
                    X = new float[] { -2, -3, -5 }
                }
            };

            var        stdout = new List <string>();
            var        stderr = new List <string>();
            ILogWriter logout = new LogWriter((string s) =>
            {
                stdout.Add(s);
            });
            ILogWriter logerr = new LogWriter((string s) =>
            {
                stderr.Add(s);
            });

            using (var host = new DelegateEnvironment(conc: 1, outWriter: logout, errWriter: logerr, verbose: 3))
                using (var ch = host.Start("Train Pipeline"))
                {
                    ComponentHelper.AddStandardComponents(host);
                    ch.Info(MessageSensitivity.All, "Polynomial");
                    var data = host.CreateStreamingDataView(inputs);
                    using (var pipe = new ScikitPipeline(new[] { "poly{col=X}" }, host: host))
                    {
                        var predictor = pipe.Train(data);
                        if (predictor == null)
                        {
                            throw new Exception("Predictor is null");
                        }
                    }
                }
            if (stdout.Count == 0)
            {
                throw new Exception("stdout is empty.");
            }
            if (stderr.Count != 0)
            {
                throw new Exception($"stderr not empty\n{string.Join("\n", stderr)}");
            }
        }
示例#21
0
        private void buttonShowWindowsTemp_Click(object sender, EventArgs e)
        {
            IComponentHelper helper = new ComponentHelper();

            dynamic fso = helper.CreateObject("Scripting.FileSystemObject");

            MessageBox.Show(this, fso.GetSpecialFolder(2).Path);
        }
示例#22
0
        private void buttonOpenWord_Click(object sender, EventArgs e)
        {
            IComponentHelper helper = new ComponentHelper();

            dynamic word = helper.CreateLocalServer("Word.Application");

            word.Visible = true;
        }
示例#23
0
        private void buttonShowWindowsTemp_Click(object sender, EventArgs e)
        {
            IComponentHelper helper = new ComponentHelper();

            dynamic fso = helper.CreateObject("Scripting.FileSystemObject");

            MessageBox.Show(this, fso.GetSpecialFolder(2).Path);
        }
示例#24
0
        private void buttonOpenWord_Click(object sender, EventArgs e)
        {
            IComponentHelper helper = new ComponentHelper();

            dynamic word = helper.CreateLocalServer("Word.Application");

            word.Visible = true;
        }
示例#25
0
        public JsonResult ComponentDelete()
        {
            string ctrlId = Request.Form[NamingCenter.PARAM_CTRL_ID];
            string pageId = Request.Form[NamingCenter.PARAM_PAGE_ID];

            ComponentHelper.DeleteComponent(pageId, ctrlId);
            return(Json(true));
        }
示例#26
0
        private void buttonGetAuthor_Click(object sender, EventArgs e)
        {
            IComponentHelper helper = new ComponentHelper();

            dynamic author = helper.GetAuthor();

            MessageBox.Show(this, author.Name);
        }
示例#27
0
        private void buttonGetAuthor_Click(object sender, EventArgs e)
        {
            IComponentHelper helper = new ComponentHelper();

            dynamic author = helper.GetAuthor();

            MessageBox.Show(this, author.Name);
        }
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            var sc   = ComponentHelper.FetchData <ScalarGrid3D>(0, DA);
            var text = ComponentHelper.FetchData <string>(1, DA);

            _renderBuffer.Add(sc);
            _renderFormat = text;
        }
 void Awake()
 {
     ComponentHelper.AssignComponentIfNotExists(gameObject, ref hud);
     ComponentHelper.AssignComponentIfNotExists(gameObject, ref progress);
     ComponentHelper.AssignComponentIfNotExists(gameObject, ref modeManager);
     ComponentHelper.AssignComponentIfNotExists(gameObject, ref result);
     ComponentHelper.AssignComponentIfNotExists(gameObject, ref character);
     ComponentHelper.AssignComponentIfNotExists(gameObject, ref cheat);
 }
示例#30
0
        protected override void OnParametersSet()
        {
            _neutralPrimary  = StyleContext.GetColorOrDefault(VariableNames.NeutralPrimary, default);
            _backgroundColor = StyleContext.GetColorOrDefault(VariableNames.ButtonBackground, VariableNames.NeutralQuaternary);

            _iconColor = StyleContext.TryGetColor(VariableNames.ButtonIcon, out var iconColor)
                ? iconColor
                : ComponentHelper.GetForegroundColor(Appearance, _backgroundColor, _neutralPrimary);
        }
示例#31
0
 private void addMLUpdaterSet()
 {
     if (mlGameState.GetComponent <MLUpdaterSet>())
     {
         Debug.Log("There already is an MLUpdaterSet");
         return;
     }
     ComponentHelper.AddIfNotPresent <MLUpdaterSet>(mlGameState.transform);
 }
示例#32
0
 private void addMLGameStateParamUpdater()
 {
     if (mlGameState.GetComponent <MLGameStateParamUpdater>())
     {
         Debug.Log("There already is an MLGameStateParamUpdater attached");
         return;
     }
     ComponentHelper.AddIfNotPresent <MLGameStateParamUpdater>(mlGameState.transform);
 }
        /// <inheritdoc />
        /// <summary>
        /// Overridden. <inherited />
        /// </summary>
        protected override void Render(HtmlTextWriter writer)
        {
            if (ComponentHelper.GetParentUpdatePanel(this) != null)
            {
                throw new InvalidOperationException("KrystalwareScriptRenderer is not valid within an UpdatePanel.");
            }

            ComponentHelper.RenderScripts(writer, ScriptInclude);
        }
示例#34
0
	/// <summary>
	/// Refresh is a very crucial function.  Not only does it refresh the abstracted lists of ObjectHelpers and ComponentHelpers to reflect the actual scene,
	/// it is responsible for actually comparing objects
	/// </summary>
	/// <returns>IEnumerable for coroutine progress</returns>
	public IEnumerable Refresh() {
		scroll = ObjectMerge.scroll;
		ObjectMerge.refreshCount++;
		same = true;
		List<GameObject> myChildren = new List<GameObject>();
		List<GameObject> theirChildren = new List<GameObject>();
		List<Component> myComponents = new List<Component>();
		List<Component> theirComponents = new List<Component>();
		//Get lists of components and children
		if (mine) {
			myChildren.AddRange(from Transform t in mine.transform select t.gameObject);
			myComponents = new List<Component>(mine.GetComponents<Component>());
		}
		if (theirs) {
			theirChildren.AddRange(from Transform t in theirs.transform select t.gameObject);
			theirComponents = new List<Component>(theirs.GetComponents<Component>());
		}
		//TODO: turn these two chunks into one function... somehow
		//Merge Components
		ComponentHelper ch;
		for (int i = 0; i < myComponents.Count; i++) {
			Component match = null;
			Component myComponent = myComponents[i];
			if (myComponent != null) {
				foreach (Component g in theirComponents) {
					if (g != null) {
						if (myComponent.GetType() == g.GetType()) {
							match = g;
							break;
						}
					}
				}
				ch = components.Find(delegate(ComponentHelper helper) {
					return helper.mine == myComponent || (match != null && helper.theirs == match);
				});
				if (ch == null) {
					ch = new ComponentHelper(this, myComponent, match);
					components.Add(ch);
				}
				else {
					ch.mine = myComponent;
					ch.theirs = match;
				}
				foreach (IEnumerable e in ch.Refresh())
					yield return e;
				if (!ComponentIsFiltered(ch.type) && !ch.same) {
					same = false;
				}
				theirComponents.Remove(match);
			}
		}
		if (theirComponents.Count > 0) {
			foreach (Component g in theirComponents) {
				ch = components.Find(delegate(ComponentHelper helper) {
					return helper.theirs == g;
				});
				if (ch == null) {
					ch = new ComponentHelper(this, null, g);
					foreach (IEnumerable e in ch.Refresh())
						yield return e;
					components.Add(ch);
				}
				if (!ComponentIsFiltered(ch.type) && !ch.same)
					same = false;
			}
		}
		//Merge Children
		ObjectHelper oh;
		for (int i = 0; i < myChildren.Count; i++) {
			GameObject match = theirChildren.FirstOrDefault(g => SameObject(myChildren[i], g));
			oh = children.Find(delegate(ObjectHelper helper) {
				return helper.mine == myChildren[i] || (match != null && helper.theirs == match);
			});
			if (oh == null) {
				oh = new ObjectHelper {parent = this, mine = myChildren[i], theirs = match};
				children.Add(oh);
			}
			else {
				oh.mine = myChildren[i];
				oh.theirs = match;
			}
			theirChildren.Remove(match);
		}
		if (theirChildren.Count > 0) {
			same = false;
			foreach (GameObject g in theirChildren) {
				oh = children.Find(delegate(ObjectHelper helper) {
					return helper.theirs == g;
				});
				if (oh == null)
					children.Add(new ObjectHelper {parent = this, theirs = g});
			}
		}
		List<ObjectHelper> tmp = new List<ObjectHelper>(children);
		foreach (ObjectHelper obj in tmp) {
			if (obj.mine == null && obj.theirs == null)
				children.Remove(obj);
		}
		children.Sort(delegate(ObjectHelper a, ObjectHelper b) {
			if (a.mine && b.mine)
				return a.mine.name.CompareTo(b.mine.name);
			if (a.mine && b.theirs)
				return a.mine.name.CompareTo(b.theirs.name);
			if (a.theirs && b.mine)
				return a.theirs.name.CompareTo(b.mine.name);
			if (a.theirs && b.theirs)
				return a.theirs.name.CompareTo(b.theirs.name);
			return 0;
		});
		tmp = new List<ObjectHelper>(children);
		foreach (ObjectHelper child in tmp) {
			foreach (IEnumerable e in child.Refresh())
				yield return e;
			if (!child.same)
				same = false;
		}
		sameAttrs = CheckAttrs();
		if (!sameAttrs && ObjectMerge.compareAttrs) {
			same = false;
		}
		ObjectMerge.scroll = scroll;
	}
示例#35
0
	public PropertyHelper(ComponentHelper parent, SerializedProperty mine, SerializedProperty theirs) {
		this.parent = parent;
		this.mine = mine;
		this.theirs = theirs;
	}