public void Disconnect(ComponentBase cmp, bool checkConn = true) { if (checkConn) { Transform prnt = cmp.transform.parent; while (prnt != null && prnt != transform) prnt = prnt.parent; if (prnt == null) return; } var children = cmp.transform.GetComponentsInChildren<ComponentBase> (); if(children != null && children.Length > 0) for (int i = 0; i < children.Length; ++i) if(cmp != children[i] && children[i] != null) Disconnect (children[i],false); foreach (Connection c in cmp.connections) { connections.Remove (c); } cmp.GetComponent<Rigidbody>().isKinematic = false; cmp.transform.parent = null; var con = connections.Where ((c) => c.pointPos == cmp.transform.position); if (con != null && con.Count() > 0) con.First ().IsAvailable = true; }
public void Connect(ComponentBase cmp) { Debug.Log ("Connecting..."); int i = CurrentIndex(); if (i == -1) return; connections[i].IsAvailable = false; cmp.GetComponent<Rigidbody>().isKinematic = true; cmp.transform.position = connections[i].pointPos; cmp.transform.LookAt(2*cmp.transform.position - connections[i].Obj.position); cmp.transform.parent = connections[i].Obj.transform; foreach(Connection c in cmp.connections) connections.Add (c); }
public static void Remove(ComponentBase componentBase) { _container.Remove(componentBase); }
public virtual void OnEntityCompRemove(EntityBase entity, string compName, ComponentBase component) { }
public void NotifyStateChanged(ComponentBase Source, string Property) => StateChanged?.Invoke(Source, Property);
// Update is called once per frame void Update() { if (RecieveInput) { if (Input.GetButtonDown("Jump")) { mBufferedJumpTime = Time.time; } CameraRotation += new Vector3(-Input.GetAxis("Mouse Y"), Input.GetAxis("Mouse X"), 0f); CameraRotation.Set(Mathf.Clamp(CameraRotation.x, -89f, 89f), CameraRotation.y, CameraRotation.z); Vector3 upOffset = new Vector3(mLeanPos.x, 3.9f, mLeanPos.z); upOffset.Normalize(); Cam.transform.rotation = Quaternion.FromToRotation(Vector3.up, upOffset) * Quaternion.Euler(CameraRotation); mInput = new Vector3(Input.GetAxis("Horizontal"), 0f, Input.GetAxis("Vertical")); Quaternion q = Quaternion.Euler(0, CameraRotation.y, 0); mInput = q * mInput; //update camera offset in acceleration leaning { ////TODO:[Gafgar: Sat/01-02-2020] add collision tracing here Cam.transform.position = Ctrl.transform.position + mCameraStartOffset + mLeanPos + q * mHeadBobOffsetSoft; } } { GameObject rayHit = null; int nbHits = Physics.RaycastNonAlloc(Cam.transform.position, Cam.transform.forward, _hitBuffer, PickupRange, -1, QueryTriggerInteraction.Ignore); if (nbHits > 0) { for (int index = nbHits; index < _hitBuffer.Length; index++) { _hitBuffer[index].distance = PickupRange * 50; } System.Array.Sort(_hitBuffer, (a, b) => (a.distance > b.distance) ? 1 : ((a.distance < b.distance) ? -1 : 0)); var obj = _hitBuffer[0].collider; if (obj.gameObject == gameObject) { if (nbHits > 1) { obj = _hitBuffer[1].collider; } else { obj = null; } } if (obj) { rayHit = obj.gameObject; } } if (mHeighlightingConnectionRemoveTimer > 0) { if (mHeighlightingConnectionRemoveTimer < 0.18f) { mHeighlightingConnectionRemoveTimer += Time.deltaTime; if (mHeighlightingConnectionRemoveTimer >= 0.18f) { mHeighlightingConnectionj = null; } } } if (rayHit != mLastHeighlightObj) { if (mLastHeighlightObj) { ComponentBase comp = mLastHeighlightObj.GetComponent <ComponentBase>(); if (comp) { comp.SetHighlighted(false); } AbstractConnection con = mLastHeighlightObj.GetComponent <AbstractConnection>(); if (con) { con.SetHighlighted(false); } } mLastHeighlightObj = rayHit; if (mHeighlightingConnectionRemoveTimer < 0) { mHeighlightingConnectionRemoveTimer = 0.01f; } bool hasSetStatusGUI = false; if (mLastHeighlightObj) { Debug.DrawLine(Cam.transform.position + Cam.transform.forward, mLastHeighlightObj.transform.position); if (!mCarryingComponent) { ComponentBase comp = mLastHeighlightObj.GetComponent <ComponentBase>(); if (comp) { comp.SetHighlighted(true); if (_statusGUI) { hasSetStatusGUI = true; _statusGUI.ShowStatusFor(comp); } } } AbstractConnection con = mLastHeighlightObj.GetComponent <AbstractConnection>(); if (con && !con.IsOccupied()) { if (mCarryingComponent) { if (con.CanConnect(mCarryingComponent)) { con.SetHighlighted(true); mHeighlightingConnectionj = con; mHeighlightingConnectionRemoveTimer = -1; } } else { con.SetHighlighted(true); } } } if (_statusGUI && !hasSetStatusGUI) { _statusGUI.ShowStatusFor(null); } } } if (Input.GetButtonDown("Fire1")) { if (!mCarryingComponent) { if (mLastHeighlightObj) { ComponentBase comp = mLastHeighlightObj.GetComponent <ComponentBase>(); if (comp) { if (comp.IsConnected()) { if (comp.CanDisconnect()) { comp.Disconnect(); } } if (!comp.IsConnected()) { Debug.Log("Picked up: " + comp.name); mCarryingComponent = comp; mCarryPosition = mCarryingComponent.transform.position; mCarryRotation = mCarryingComponent.transform.rotation; mCarryTime = 0; Collider[] colliders = mCarryingComponent.GetComponentsInChildren <Collider>(); foreach (Collider c in colliders) { c.enabled = false; } mCarryingComponent._Body.isKinematic = true; if (Audio.Music.EventInstance.hasHandle() && !mCarryingComponent._isWorking) { Audio.Music.SetParameter("Glitch", 1.0f); } } } } } else { Collider[] colliders = mCarryingComponent.GetComponentsInChildren <Collider>(); foreach (Collider c in colliders) { c.enabled = true; } if (mLastHeighlightObj) { AbstractConnection con = mLastHeighlightObj.GetComponent <AbstractConnection>(); if (con) { if (con.CanConnect(mCarryingComponent)) { mCarryingComponent.ConnectTo(con); } } } if (!mCarryingComponent.IsConnected()) { Debug.Log("Dropped: " + mCarryingComponent.name); mCarryingComponent._Body.isKinematic = false; mCarryingComponent._Body.AddForce(Cam.transform.forward * 2000); mVelocitySoft += (new Vector3(-10.0f * Cam.transform.forward.x, 0.0f, -10.0f * Cam.transform.forward.z)); if (Audio.Music.EventInstance.hasHandle()) { Audio.Music.SetParameter("Glitch", 0.0f); } } else { mVelocitySoft += (new Vector3(3.0f * Cam.transform.forward.x, -2.0f, 3.0f * Cam.transform.forward.z)); Debug.Log("Connected: " + mCarryingComponent.name + " to " + mCarryingComponent._Connection.name); } mCarryingComponent = null; } } }
/// <summary> /// Create a component instance from a vehicle /// </summary> public Component(Vehicle vehicle, ComponentType type, ComponentBase relativeBase = ComponentBase.root) { this.vehicle = vehicle; this.component = type.ToString().ToLower(); Base = relativeBase; }
public void DispatchCompChange(EntityBase entity, string compName, ComponentBase previousComponent, ComponentBase newComponentt) { if (OnEntityComponentChange != null) { OnEntityComponentChange(entity, compName, previousComponent, newComponentt); } }
public void UpdateSelectedWorkWeek(ComponentBase src, WorkWeek ww) { this.SelectedWorkWeek = ww; Console.WriteLine("SelectedWorkWee: " + ww.ToString()); NotifyStateChanged(src, "SelectedWorkWeek"); }
public void UpdateSelectedCalendarWeek(ComponentBase src, string calWeek) { this.SelectedCalendarWeek = calWeek; Console.WriteLine("SelectedCalendarWeek: " + calWeek); NotifyStateChanged(src, "SelectedCalendarWeek"); }
public async Task CopyAsync([FromBody] ComponentBase model) { await _facade.CopyAsync(model.Type, model.Id); }
public void AddComponent(ComponentBase component) { componentList.Add(component); component.SetComponent(this, Transform); }
public void SetAuthState(ComponentBase source, User user, bool isAuthenticated) { IsAuth = isAuthenticated; User = user; NotifyStateChanged(source, "auth"); }
public void UpdateExpenseLimits(ComponentBase source, List <ExpenseLimit> expenseLimits) { ExpenseLimits = expenseLimits; NotifyStateChanged(source, "expenseLimits"); }
public static void RegisterComponent(ComponentBase component) { _components.Add(component); }
/// <summary> /// 注册Component /// </summary> /// <param name="configBean">component</param> public void Register(ComponentBase component) { ComponentContainer.Current.Register(component); }
public void UpdatedSelectedWorkShift(ComponentBase src, WorkShift ws) { this.SelectedWorkShift = ws; Console.WriteLine("SelectedWorkShift: " + ws.ToString()); NotifyStateChanged(src, "SelectedWorkShift"); }
public void UpdateTransactions(ComponentBase source, List <Transaction> transactions) { Transactions = transactions; NotifyStateChanged(source, "transactions"); }
public void UpdateCalDisplayMonth(ComponentBase src, DateTime dte) { this.CalDisplayMonth = dte; NotifyStateChanged(src, "CalDisplayMonth"); }
public override void AddComponentBase(ComponentBase componentBase) { base.AddComponentBase(componentBase); LocalDataComponent.SetSaveAction(LocalDataHelper.SaveAllGameData); }
protected override Entity AddComponentAndDispatchAddEvent(ComponentBase comp, Type compCls) { bool flag = false; if (comp is AreaTriggerComponent) { this.AreaTriggerComp = (AreaTriggerComponent)comp; flag = true; } if (comp is ArmoryComponent) { this.ArmoryComp = (ArmoryComponent)comp; flag = true; } if (comp is AssetComponent) { this.AssetComp = (AssetComponent)comp; flag = true; } if (comp is AttackerComponent) { this.AttackerComp = (AttackerComponent)comp; flag = true; } if (comp is BarracksComponent) { this.BarracksComp = (BarracksComponent)comp; flag = true; } if (comp is BoardItemComponent) { this.BoardItemComp = (BoardItemComponent)comp; flag = true; } if (comp is BuildingAnimationComponent) { this.BuildingAnimationComp = (BuildingAnimationComponent)comp; flag = true; } if (comp is BuildingComponent) { this.BuildingComp = (BuildingComponent)comp; flag = true; } if (comp is ChampionComponent) { this.ChampionComp = (ChampionComponent)comp; flag = true; } if (comp is CivilianComponent) { this.CivilianComp = (CivilianComponent)comp; flag = true; } if (comp is ClearableComponent) { this.ClearableComp = (ClearableComponent)comp; flag = true; } if (comp is DamageableComponent) { this.DamageableComp = (DamageableComponent)comp; flag = true; } if (comp is DefenderComponent) { this.DefenderComp = (DefenderComponent)comp; flag = true; } if (comp is DefenseLabComponent) { this.DefenseLabComp = (DefenseLabComponent)comp; flag = true; } if (comp is DroidComponent) { this.DroidComp = (DroidComponent)comp; flag = true; } if (comp is DroidHutComponent) { this.DroidHutComp = (DroidHutComponent)comp; flag = true; } if (comp is SquadBuildingComponent) { this.SquadBuildingComp = (SquadBuildingComponent)comp; flag = true; } if (comp is NavigationCenterComponent) { this.NavigationCenterComp = (NavigationCenterComponent)comp; flag = true; } if (comp is FactoryComponent) { this.FactoryComp = (FactoryComponent)comp; flag = true; } if (comp is CantinaComponent) { this.CantinaComp = (CantinaComponent)comp; flag = true; } if (comp is FleetCommandComponent) { this.FleetCommandComp = (FleetCommandComponent)comp; flag = true; } if (comp is FollowerComponent) { this.FollowerComp = (FollowerComponent)comp; flag = true; } if (comp is GameObjectViewComponent) { this.GameObjectViewComp = (GameObjectViewComponent)comp; flag = true; } if (comp is GeneratorComponent) { this.GeneratorComp = (GeneratorComponent)comp; flag = true; } if (comp is GeneratorViewComponent) { this.GeneratorViewComp = (GeneratorViewComponent)comp; flag = true; } if (comp is HealerComponent) { this.HealerComp = (HealerComponent)comp; flag = true; } if (comp is TroopShieldComponent) { this.TroopShieldComp = (TroopShieldComponent)comp; flag = true; } if (comp is TroopShieldViewComponent) { this.TroopShieldViewComp = (TroopShieldViewComponent)comp; flag = true; } if (comp is TroopShieldHealthComponent) { this.TroopShieldHealthComp = (TroopShieldHealthComponent)comp; flag = true; } if (comp is HealthComponent) { this.HealthComp = (HealthComponent)comp; flag = true; } if (comp is HealthViewComponent) { this.HealthViewComp = (HealthViewComponent)comp; flag = true; } if (comp is HQComponent) { this.HQComp = (HQComponent)comp; flag = true; } if (comp is KillerComponent) { this.KillerComp = (KillerComponent)comp; flag = true; } if (comp is LootComponent) { this.LootComp = (LootComponent)comp; flag = true; } if (comp is MeterShaderComponent) { this.MeterShaderComp = (MeterShaderComponent)comp; flag = true; } if (comp is OffenseLabComponent) { this.OffenseLabComp = (OffenseLabComponent)comp; flag = true; } if (comp is PathingComponent) { this.PathingComp = (PathingComponent)comp; flag = true; } if (comp is SecondaryTargetsComponent) { this.SecondaryTargetsComp = (SecondaryTargetsComponent)comp; flag = true; } if (comp is ShieldBorderComponent) { this.ShieldBorderComp = (ShieldBorderComponent)comp; flag = true; } if (comp is ShieldGeneratorComponent) { this.ShieldGeneratorComp = (ShieldGeneratorComponent)comp; flag = true; } if (comp is SizeComponent) { this.SizeComp = (SizeComponent)comp; flag = true; } if (comp is ShooterComponent) { this.ShooterComp = (ShooterComponent)comp; flag = true; } if (comp is StarportComponent) { this.StarportComp = (StarportComponent)comp; flag = true; } if (comp is StateComponent) { this.StateComp = (StateComponent)comp; flag = true; } if (comp is StorageComponent) { this.StorageComp = (StorageComponent)comp; flag = true; } if (comp is SupportComponent) { this.SupportComp = (SupportComponent)comp; flag = true; } if (comp is SupportViewComponent) { this.SupportViewComp = (SupportViewComponent)comp; flag = true; } if (comp is TacticalCommandComponent) { this.TacticalCommandComp = (TacticalCommandComponent)comp; flag = true; } if (comp is ChampionPlatformComponent) { this.ChampionPlatformComp = (ChampionPlatformComponent)comp; flag = true; } if (comp is TeamComponent) { this.TeamComp = (TeamComponent)comp; flag = true; } if (comp is TrackingComponent) { this.TrackingComp = (TrackingComponent)comp; flag = true; } if (comp is TrackingGameObjectViewComponent) { this.TrackingGameObjectViewComp = (TrackingGameObjectViewComponent)comp; flag = true; } if (comp is TransformComponent) { this.TransformComp = (TransformComponent)comp; flag = true; } if (comp is TransportComponent) { this.TransportComp = (TransportComponent)comp; flag = true; } if (comp is TroopComponent) { this.TroopComp = (TroopComponent)comp; flag = true; } if (comp is TurretBuildingComponent) { this.TurretBuildingComp = (TurretBuildingComponent)comp; flag = true; } if (comp is TurretShooterComponent) { this.TurretShooterComp = (TurretShooterComponent)comp; flag = true; } if (comp is WalkerComponent) { this.WalkerComp = (WalkerComponent)comp; flag = true; } if (comp is WallComponent) { this.WallComp = (WallComponent)comp; flag = true; } if (comp is BuffComponent) { this.BuffComp = (BuffComponent)comp; flag = true; } if (comp is TrapComponent) { this.TrapComp = (TrapComponent)comp; flag = true; } if (comp is TrapViewComponent) { this.TrapViewComp = (TrapViewComponent)comp; flag = true; } if (comp is HousingComponent) { this.HousingComp = (HousingComponent)comp; flag = true; } if (comp is ScoutTowerComponent) { this.ScoutTowerComp = (ScoutTowerComponent)comp; flag = true; } if (!flag && compCls != null) { Service.Get <StaRTSLogger>().Error("Invalid component add: " + compCls.get_Name()); } return(base.AddComponentAndDispatchAddEvent(comp, compCls)); }
/// <summary> /// Create a component instance from a vehicle using a string as type /// </summary> public Component(Vehicle vehicle, string type, ComponentBase relativeBase = ComponentBase.root) { this.vehicle = vehicle; this.component = type; Base = relativeBase; }
public virtual void OnEntityCompRemove(EntityBase entity, int compIndex, ComponentBase component) { }
public void UpdateSelectedCompany(ComponentBase Source, string selectedComany) { this.selectedCompanyCode = selectedComany; NotifyStateChanged(Source, selectedComany); }
public virtual void OnEntityCompChange(EntityBase entity, int compIndex, ComponentBase previousComponent, ComponentBase newComponent) { }
public void Copy() { // Things that we should consider: // - when copy an object that is selected, we must save its absolute position instead of relative Top, Left. // This is necessary when copying several objects that have different parents. // - when copy a parent object and its child, and both are selected, we must exclude a child from the // selected objects. This is necessary to avoid duplicate copy of the child object - it will be // copied by its parent. if (FDesigner.SelectedObjects == null) { return; } using (ClipboardParent parent = new ClipboardParent()) { Hashtable bounds = new Hashtable(); parent.PageType = FDesigner.SelectedObjects[0].Page.GetType(); foreach (Base c in FDesigner.Objects) { if (c.IsSelected) { if (c.HasFlag(Flags.CanCopy)) { if (!parent.Contains(c)) { if (c is ComponentBase) { ComponentBase c1 = c as ComponentBase; bounds[c1] = c1.Bounds; c1.SetDesigning(false); c1.Left = c1.AbsLeft; c1.Top = c1.AbsTop; } parent.Objects.Add(c); } } } } using (MemoryStream stream = new MemoryStream()) using (FRWriter writer = new FRWriter()) { writer.SerializeTo = SerializeTo.Clipboard; writer.Write(parent); writer.Save(stream); Clipboard.SetData("FastReport", stream); } // restore components' state foreach (Base c in parent.Objects) { if (c is ComponentBase) { ComponentBase c1 = c as ComponentBase; if (bounds[c1] != null) { c1.Bounds = (RectangleF)bounds[c1]; } c1.SetDesigning(true); } } } }
void DispatchEntityComponentChange(EntityBase entity, int compIndex, ComponentBase previousComponent, ComponentBase newComponent) { if (OnEntityComponentChange != null) { OnEntityComponentChange(entity, compIndex, previousComponent, newComponent); } }
public virtual void OnEntityCompChange(EntityBase entity, string compName, ComponentBase previousComponent, ComponentBase newComponent) { }
/// <summary> /// 生成组件 Id 字符串 /// </summary> /// <param name="component"></param> /// <returns></returns> public string Generate(ComponentBase component) => $"bb_{component.GetHashCode()}";
/// <summary> /// Write a simgle component in file /// </summary> /// <param name="component">Component to be writen</param> /// <param name="writer">File generator</param> private static void WriteComponent(ComponentBase component, XmlWriter writer) { string componentTypeName = component.GetType().ToString().Replace("Core.Components.", string.Empty); writer.WriteStartElement(componentTypeName); if (component is NameableComponent) { writer.WriteStartAttribute("Name"); writer.WriteValue((component as NameableComponent).Name); writer.WriteEndAttribute(); } switch (componentTypeName) { #region Basic case "Coil": writer.WriteStartAttribute("Mode"); writer.WriteValue((component as Coil).Mode.ToString()); writer.WriteEndAttribute(); writer.WriteStartAttribute("Type"); writer.WriteValue((component as Coil).Type.ToString()); writer.WriteEndAttribute(); break; case "Contact": writer.WriteStartAttribute("IsClosed"); writer.WriteValue((component as Contact).IsClosed); writer.WriteEndAttribute(); writer.WriteStartAttribute("IsInverted"); writer.WriteValue((component as Contact).IsInverted); writer.WriteEndAttribute(); writer.WriteStartAttribute("Type"); writer.WriteValue((component as Contact).Type.ToString()); writer.WriteEndAttribute(); break; #endregion Basic #region Compare Components case "EQU": case "GEQ": case "GRT": case "LEG": case "LES": case "NEQ": writer.WriteStartAttribute("VarA"); writer.WriteValue((component as CompareComponent).VarA); writer.WriteEndAttribute(); writer.WriteStartAttribute("VarB"); writer.WriteValue((component as CompareComponent).VarB); writer.WriteEndAttribute(); break; #endregion Compare Components #region Counter Components case "CTC": case "CTD": case "CTU": writer.WriteStartAttribute("Limit"); writer.WriteValue((component as CounterComponent).Limit); writer.WriteEndAttribute(); break; #endregion Counter Components #region Math Components case "ADD": case "DIV": case "MUL": case "SUB": case "MOV": writer.WriteStartAttribute("Destination"); writer.WriteValue((component as MathComponent).Destination); writer.WriteEndAttribute(); writer.WriteStartAttribute("VarA"); writer.WriteValue((component as MathComponent).VarA); writer.WriteEndAttribute(); writer.WriteStartAttribute("VarB"); writer.WriteValue((component as MathComponent).VarB); writer.WriteEndAttribute(); break; #endregion Math Components #region Analog Components case "ADC": writer.WriteStartAttribute("Destination"); writer.WriteValue((component as ADC).Destination); writer.WriteEndAttribute(); break; case "PWM": writer.WriteStartAttribute("DudyCycle"); writer.WriteValue((component as PWM).DudyCycle); writer.WriteEndAttribute(); break; #endregion Analog Components #region Function Components case "ELF": writer.WriteStartAttribute("Name"); writer.WriteValue((component as ELF).Name); writer.WriteEndAttribute(); break; #endregion Function Components #region Components that do not require any extra processing case "OSF": case "OSR": case "SC": case "RES": //Nothing to do were break; #endregion Components that do not require any extra processing default: throw new ArgumentException("Unknow Component", "component"); } writer.WriteStartAttribute("Comment"); writer.WriteValue(component.Comment); writer.WriteEndAttribute(); writer.WriteEndElement(); }
/// <summary> /// Initialize the scoped component /// </summary> /// <param name="componentId">Id of the component</param> /// <param name="embeddedCssPath">Embedded css path inside the assembly</param> /// <returns>Returns if has changed style tag</returns> internal async Task <bool> InitializeComponent(ScopedStyle component, string embeddedCssPath, ComponentBase parent) { if (component.ReuseCss && component.Parent != null) { if (_renderedStyles.ContainsKey(component.Id)) { return(false); } } if (!_cssBag.Styles.TryGetValue(embeddedCssPath, out string css)) { if (parent != null) { embeddedCssPath = $"{parent.GetType().Namespace}.{embeddedCssPath}"; } if (!_cssBag.Styles.TryGetValue(embeddedCssPath, out css)) { throw new ArgumentException($"Embedded css path {embeddedCssPath} not found. Did you set the build action of the file as EmbeddedResource on Visual Studio?"); } } _renderedStyles.Add(component.Id, css); await _jsInterop.InnerHTML( _configuration.StyleHtmlTagName, _renderedStyles .Select(s => s.Value.Replace(_configuration.CssSelectorToReplace, s.Key.ToString())) .Aggregate((a, b) => $"{a} {b}") ); return(true); }
static public void CompareComponents(ComponentBase cb1, ComponentBase cb2) { Type type = cb1.GetType(); Assert.IsTrue(type == cb2.GetType(), "Types do not match"); FieldInfo[] fields = type.GetFields(); PropertyInfo[] properties = type.GetProperties(); foreach (FieldInfo field in fields) { if (field.GetCustomAttributes(typeof(Serialized), true).Length > 0) { object obj1 = field.GetValue(cb1); object obj2 = field.GetValue(cb2); if (field.FieldType.IsArray) CompareArrays(obj1 as Array, obj2 as Array, field.Name); else Assert.IsTrue(object.Equals(obj1, obj2), field.Name + " does not match"); } } foreach (PropertyInfo prop in properties) { if (prop.GetCustomAttributes(typeof(Serialized), true).Length > 0) { object obj1 = prop.GetValue(cb1, null); object obj2 = prop.GetValue(cb2, null); if (prop.PropertyType.IsArray) CompareArrays(obj1 as Array, obj2 as Array, prop.Name); else Assert.IsTrue(object.Equals(obj1, obj2), prop.Name + " does not match"); } } }
private void CompareComponents(ComponentBase cb1, ComponentBase cb2) { Type type = cb1.GetType(); Assert.IsTrue(type == cb2.GetType(), "Types do not match"); FieldInfo[] fields = type.GetFields(); foreach (FieldInfo field in fields) { if (field.GetCustomAttributes(typeof(NotSerialized), true).Length == 0) { object obj1 = field.GetValue(cb1); object obj2 = field.GetValue(cb2); if (field.FieldType.IsArray) CompareArrays(obj1 as Array, obj2 as Array, field.Name); else Assert.IsTrue(object.Equals(obj1, obj2), field.Name + " does not match"); } } }
/// <summary> /// Loads the view from the specified stream. /// </summary> public override void LoadView(Stream stream) { // add template bindings as resource if (!string.IsNullOrEmpty(templateArgs.BindingFileName)) { Resources.Add(new ViewResource { Name = nameof(TemplateBindings), Path = templateArgs.BindingFileName }); } // load XML document XmlDocument xmlDoc = new(); xmlDoc.Load(stream); // check data format XmlElement rootElem = xmlDoc.DocumentElement; if (!rootElem.Name.Equals("SchemeView", StringComparison.OrdinalIgnoreCase)) { throw new ScadaException(CommonPhrases.InvalidFileFormat); } // load scheme document if (rootElem.SelectSingleNode("Scheme") is XmlNode schemeNode) { SchemeDoc.LoadFromXml(schemeNode); // update scheme title if (string.IsNullOrEmpty(Title) && !string.IsNullOrEmpty(SchemeDoc.Title)) { Title = SchemeDoc.Title; } } // load scheme components if (rootElem.SelectSingleNode("Components") is XmlNode componentsNode) { HashSet <string> errNodeNames = new(); // node names of unloaded components LoadErrors.AddRange(CompManager.LoadErrors); foreach (XmlNode compNode in componentsNode.ChildNodes) { // create component ComponentBase component = CompManager.CreateComponent(compNode, out string errMsg); if (component == null) { component = new UnknownComponent { XmlNode = compNode }; if (errNodeNames.Add(compNode.Name)) { LoadErrors.Add(errMsg); } } // load component and add it to view component.SchemeView = this; component.LoadFromXml(compNode); Components[component.ID] = component; // get max component ID if (component.ID > maxComponentID) { maxComponentID = component.ID; } } } // load scheme images if (rootElem.SelectSingleNode("Images") is XmlNode imagesNode) { Dictionary <string, Image> images = SchemeDoc.Images; XmlNodeList imageNodes = imagesNode.SelectNodes("Image"); foreach (XmlNode imageNode in imageNodes) { Image image = new(); image.LoadFromXml(imageNode); if (!string.IsNullOrEmpty(image.Name)) { images[image.Name] = image; } } } }
/// <summary> /// Initializes a new instance of the <see cref="PreConfirmCallback"/> class. /// Creates a <see cref="PreConfirmCallback"/> for the provided <paramref name="receiver"/> and <paramref name="callback"/>. /// <para>Use in Queue requests.</para> /// </summary> /// <param name="callback">The event callback.</param> /// <param name="receiver">The event receiver. Pass in `this` from the calling component.</param> /// <exception cref="ArgumentException">Thrown if used in Fire request.</exception> public PreConfirmCallback(Func <IEnumerable <string>, Task <IEnumerable <string> > > callback, ComponentBase receiver = null) { this.asyncQueueCallback = callback; if (receiver != null) { this.eventCallback = EventCallback.Factory.Create(receiver, () => { }); } }
public void MyTestInitialize() { myComponent = new MyComponent { Count = this.count, PageName = this.pageName, PageID = this.pageID }; }