public CtorHavingType(NestingType nesting, string text, int value, double otherValue) { Nesting = nesting; Text = text; Value = value; OtherValue = otherValue; }
public CtorHavingType(NestingType nesting, string text, int value, double otherValue) { Nesting = nesting; Text = text; Value = value; OtherValue = otherValue; }
private XElement FindDerivedElement(NestingType nestingType, XElement element, String derivedElementName, RegisterSettings defaultRegisterSettings, out RegisterSettings outRegisterSettings) { string[] derivedSplitNode = derivedElementName.Split('.'); outRegisterSettings = defaultRegisterSettings; XElement derivedElement; if (derivedSplitNode.Length == 1) { derivedElement = GetDerivedElementFromTheScope( element, element.Parent.Elements(), nestingType, derivedElementName ); } else { var derivedPeripheral = GetDerivedElementFromTheScope( element, deviceNode.Element("peripherals").Elements(), NestingType.Peripheral, derivedSplitNode[0] ); outRegisterSettings = GetRegisterSettings(derivedPeripheral, defaultRegisterSettings); derivedElement = derivedPeripheral.Element("registers"); // if we are deriving from the cluster we should go through all cluster in the cluster chain, // but if we are deriving from register we should go through all cluster chain but last one. var limit = derivedSplitNode.Length - (nestingType == NestingType.Register ? 1 : 0); for (var i = 1; i < limit; i++) { derivedElement = GetDerivedElementFromTheScope( derivedElement, derivedElement.Elements("cluster"), NestingType.Cluster, derivedSplitNode[i] ); var address = CalculateOffset( outRegisterSettings.Address, GetAddressOffset(derivedElement) ); outRegisterSettings = GetRegisterSettings(derivedElement, outRegisterSettings, address); } // If we are deriving from the register, we must find this register in the last cluster in the chain. if (nestingType == NestingType.Register) { derivedElement = derivedElement.Elements("register").First(x => x.Element("name").Value == derivedSplitNode[derivedSplitNode.Length - 1]); } } outRegisterSettings = GetRegisterSettings(derivedElement, outRegisterSettings, defaultRegisterSettings.Address); return(derivedElement); }
public void Inject_references_by_ctor_using_generic_constructor_arguments() { _ctx.RegisterNamed <CtorHavingType>("test") .BindConstructorArg <NestingType>().ToRegistered("nesting"); _ctx.RegisterNamed <NestingType>("nesting"); NestingType actual = _ctx.GetObject <CtorHavingType>("test").Nesting; NestingType expected = _ctx.GetObject <NestingType>("nesting"); Assert.That(actual, Is.SameAs(expected)); }
public void Inject_default_references_by_ctor() { _ctx.RegisterDefault <CtorHavingType>() .BindConstructorArg <NestingType>().ToRegisteredDefault(); _ctx.RegisterDefault <NestingType>(); NestingType actual = _ctx.GetDefaultObject <CtorHavingType>().Nesting; NestingType expected = _ctx.GetDefaultObject <NestingType>(); Assert.That(actual, Is.SameAs(expected)); }
public void Inject_typed_references_by_ctor() { var nestedRef = _ctx.RegisterNamed <NestingType>("nested").GetReference(); _ctx.RegisterDefault <CtorHavingType>() .BindConstructorArg <NestingType>().ToRegistered(nestedRef); NestingType actual = _ctx.GetDefaultObject <CtorHavingType>().Nesting; NestingType expected = _ctx.GetObject <NestingType>("nested"); Assert.That(actual, Is.SameAs(expected)); }
public void OnDrag(PointerEventData eventData) { IsBeingDragged = true; bloxTransform.position = eventData.position; // If this blox has child bloxes and params, sets their positions in // order to drag them also RootBlox rootBlox = GetRootBlox(); if (rootBlox != null) { float bloxVerticalSpacing = GetVerticalSpacing(rootBlox); float identSpacing = GetIdentSpacing(rootBlox); float paramSpacing = GetParamSpacing(rootBlox); // Sets the child blox and params position while dragging, for them to follow this blox // Those bloxes nesting is temporarily disabled SetChildBloxesPositionOnScreen(this, bloxVerticalSpacing, identSpacing, paramSpacing, false); } // Verifies if there are collided objects, and if // this object can be potentially nested to those if (collidedObjects.Count > 0) { // Although we are saving all the simultaneous collisions // We only want this object to nest with the highest ones float maxY = collidedObjects.Max(c => c.transform.position.y); List <GameObject> highestObjects = collidedObjects.Where(c => c.transform.position.y == maxY).Select(a => a.gameObject).ToList(); ResetHightlight(); foreach (GameObject collidedObject in highestObjects) { //If the collided object is a blox, checks if this is nestable to it, and hightlights if it is if (GameObjectHelper.HasComponent <ABlox>(collidedObject)) { NestingType nestingType = collidedObject.GetComponent <ABlox>().DetermineNestingType(this.gameObject); if (nestingType != NestingType.NONE && GameObjectHelper.HasComponent <HighlightableButton>(collidedObject.gameObject)) { HighlightableButton hB = collidedObject.gameObject.GetComponent <HighlightableButton>(); hB.HighlightButton(HighlightableButton.ButtonHighlight.Info); hightlightableBloxes.Add(hB); } } } } }
/// <summary> /// Checks if object passed can be nested to this one, and returns nesting type /// </summary> /// <param name="secondObject"></param> /// <returns></returns> public NestingType DetermineNestingType(GameObject secondObject) { NestingType nestingType = NestingType.NONE; RootBlox rootBlox = GetRootBlox(); if (rootBlox != null && NestingActive) { if (secondObject.GetComponent <ABlox>() != null && secondObject != null && ValidateNesting(secondObject)) { ABlox secondObjectBlox = secondObject.GetComponent <ABlox>(); Vector2 thisObjectPosition = this.gameObject.transform.position; BoundingBox2D thisBBox = GameObjectHelper.getBoundingBoxInWorld(this.gameObject); BoundingBox2D secondObjBBox = GameObjectHelper.getBoundingBoxInWorld(secondObject); float thisObjectWidth = GameObjectHelper.getWidthFromBBox(thisBBox); float thisObjectHeight = GameObjectHelper.getHeightFromBBox(thisBBox); //checks if second object top is bellow this object center if (secondObjBBox.top.y < thisObjectPosition.y) { if (!secondObjectBlox.IsParam && ValidateNestToBottom(secondObject) && MathHelper.IsNearby(secondObjBBox.left.x, thisBBox.left.x, thisObjectWidth / 4)) { nestingType = NestingType.BOTTOM; } else if (!secondObjectBlox.IsParam && ValidateNestToBottomIdented(secondObject) && MathHelper.IsNearby(secondObjBBox.left.x, thisBBox.bottom.x, thisObjectWidth / 4)) { nestingType = NestingType.BOTTOM_IDENTED; } } else //if it is above { // Checks if the left parth of the second object is near the right part of the first, and verifies if they are kind of aligned if (ValidateNestToTheSide(secondObject) && MathHelper.IsNearby(secondObjBBox.left.y, thisBBox.right.y, thisObjectHeight / 4) && MathHelper.IsNearby(secondObjBBox.left.x, thisBBox.right.x, thisObjectWidth / 4)) { // Nest side to side nestingType = NestingType.SIDE; } } } } return(nestingType); }
public ParserManager(Algorithm algo, NestingType nesting, Unit unit) : base() { switch (algo) { case Algorithm.LL: if (nesting == NestingType.Recursion && unit == Unit.Lexeme) { parser = new LexingParser(Grammar); } else if (nesting == NestingType.Stack && unit == Unit.Character) { parser = new StackParser(Grammar); } break; default: throw new Exception(); } }
public bool IsGlobalType() { if (!IsNested()) { return(TypeDef.IsPublic); } switch (TypeDef.Visibility) { case TypeAttributes.NestedPrivate: case TypeAttributes.NestedAssembly: case TypeAttributes.NestedFamANDAssem: return(false); case TypeAttributes.NestedPublic: case TypeAttributes.NestedFamily: case TypeAttributes.NestedFamORAssem: return(NestingType.IsGlobalType()); default: return(false); } }
public bool isGlobalType() { if (!isNested()) { return(TypeDefinition.IsPublic); } var mask = TypeDefinition.Attributes & TypeAttributes.VisibilityMask; switch (mask) { case TypeAttributes.NestedPrivate: case TypeAttributes.NestedAssembly: case TypeAttributes.NestedFamANDAssem: return(false); case TypeAttributes.NestedPublic: case TypeAttributes.NestedFamily: case TypeAttributes.NestedFamORAssem: return(NestingType.isGlobalType()); default: return(false); } }
public string BuildXSD(string xml, NestingType type) { generationType = type; //Create schema element XmlSchema schema = new XmlSchema(); schema.ElementFormDefault = XmlSchemaForm.Qualified; schema.AttributeFormDefault = XmlSchemaForm.Unqualified; schema.Version = "1.0"; //Add additional namespaces using the Add() method shown below //if desired XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); ns.Add("xsd", schemaNS); ns.Add("xs", "http://www.w3.org/2001/XMLSchema"); ns.Add("msdata", "urn:schemas-microsoft-com:xml-msdata"); schema.Namespaces = ns; //Begin parsing source XML document XmlDocument doc = new XmlDocument(); try { //Assume string XML doc.LoadXml(xml); } catch { try { //String XML load failed. Try loading as a file path doc.Load(xml); } catch { return "XML document is not well-formed."; } } XmlElement root = doc.DocumentElement; //Create root element definition for schema //Call CreateComplexType to either add a complexType tag //or simply add the necesary schema attributes XmlSchemaElement elem = CreateComplexType(root); //Add root element definition into the XmlSchema object schema.Items.Add(elem); //Reverse elements in ArrayList so root complexType appears first //where applicable complexTypes.Reverse(); //In cases where the user wants to separate out the complexType tags //loop through the complexType ArrayList and add the types to the schema foreach(object obj in complexTypes) { XmlSchemaComplexType ct = (XmlSchemaComplexType)obj; schema.Items.Add(ct); } //Compile the schema and then write its contents to a StringWriter try { XmlSchemaSet xss = new XmlSchemaSet(); xss.Add(schema); xss.ValidationEventHandler += new ValidationEventHandler(ValidateSchema); xss.Compile(); StringWriter sw = new StringWriter(); string retval = sw.ToString(); schema.Write(sw); sw.Flush(); sw.Close(); sw.Dispose(); return retval; } catch (Exception exp) { return exp.Message; } }
public CtorHavingType(NestingType nesting) : this(nesting, null, 0) { }
public CtorHavingType(NestingType nesting, string text, int value) : this(nesting, text, value, 0.0) { }
public CtorHavingType(NestingType nesting) : this(nesting, null, 0) { }
public CtorHavingType(NestingType nesting, string text, int value) : this(nesting, text, value, 0.0) { }
public string BuildXSD(string xml, NestingType type) { generationType = type; //Create schema element XmlSchema schema = new XmlSchema(); schema.ElementFormDefault = XmlSchemaForm.Qualified; schema.AttributeFormDefault = XmlSchemaForm.Unqualified; schema.Version = "1.0"; //Add additional namespaces using the Add() method shown below //if desired XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); ns.Add("xsd", schemaNS); ns.Add("xs", "http://www.w3.org/2001/XMLSchema"); ns.Add("msdata", "urn:schemas-microsoft-com:xml-msdata"); schema.Namespaces = ns; //Begin parsing source XML document XmlDocument doc = new XmlDocument(); try { //Assume string XML doc.LoadXml(xml); } catch { try { //String XML load failed. Try loading as a file path doc.Load(xml); } catch { return("XML document is not well-formed."); } } XmlElement root = doc.DocumentElement; //Create root element definition for schema //Call CreateComplexType to either add a complexType tag //or simply add the necesary schema attributes XmlSchemaElement elem = CreateComplexType(root); //Add root element definition into the XmlSchema object schema.Items.Add(elem); //Reverse elements in ArrayList so root complexType appears first //where applicable complexTypes.Reverse(); //In cases where the user wants to separate out the complexType tags //loop through the complexType ArrayList and add the types to the schema foreach (object obj in complexTypes) { XmlSchemaComplexType ct = (XmlSchemaComplexType)obj; schema.Items.Add(ct); } //Compile the schema and then write its contents to a StringWriter try { XmlSchemaSet xss = new XmlSchemaSet(); xss.Add(schema); xss.ValidationEventHandler += new ValidationEventHandler(ValidateSchema); xss.Compile(); StringWriter sw = new StringWriter(); string retval = sw.ToString(); schema.Write(sw); sw.Flush(); sw.Close(); sw.Dispose(); return(retval); } catch (Exception exp) { return(exp.Message); } }
private XElement GetDerivedElementFromTheScope(XElement element, IEnumerable <XElement> collection, NestingType type, string derivedName) { var result = collection.FirstOrDefault(x => x.Name == type.ToString().ToLower() && ElementNameEquals(x, derivedName)); if (result == null) { var name = GetMandatoryField(element, "name"); throw new RecoverableException($"The SVD {type} '{name}' derives from '{derivedName}', but '{derivedName}' cannot be found."); } return(result); }