void Register(ChildInfo c, LeaveToObserveEngineViewModel viewModel) { // Todo :发送登记信息 Application.Current.Dispatcher.Invoke(() => { viewModel.Message.Insert(0, "儿童:" + c.Name + "预防接种登记成功"); this.DownLoadList(viewModel); // Todo :更新列表 LeaveToObserveItemViewModel observeitem = new LeaveToObserveItemViewModel(); observeitem.Seq = c.ID; observeitem.Name = c.Name; observeitem.Sex = "男"; observeitem.StartTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); observeitem.CreateTime = "30"; viewModel.Collection.Add(observeitem); }); //MessageProvider.Instance.ShowWithLog("儿童:" + c.Name + "预防接种登记成功"); }
public void TestChildListInsert() { DomNodeType type = new DomNodeType("type"); ChildInfo childInfo = new ChildInfo("child", type, true); type.Define(childInfo); DomNode parent = new DomNode(type); IList <DomNode> list = parent.GetChildList(childInfo); DomNode child1 = new DomNode(type); list.Insert(0, child1); Utilities.TestSequenceEqual(list, child1); // insertion again will cause removal, then insertion list.Insert(0, child1); Utilities.TestSequenceEqual(list, child1); DomNode child2 = new DomNode(type); list.Insert(0, child2); Utilities.TestSequenceEqual(list, child2, child1); }
public void TestCustomChildInfo() { DomNodeType type = new DomNodeType("foo"); ChildInfo info = new ChildInfo("foo", type); DomNodeType test = new DomNodeType( "test", null, EmptyEnumerable <AttributeInfo> .Instance, new ChildInfo[] { info }, EmptyEnumerable <ExtensionInfo> .Instance); Utilities.TestSequenceEqual(test.Children, info); Assert.True(test.IsValid(info)); Assert.AreSame(test.GetChildInfo("foo"), info); // check that type is now frozen Assert.Throws <InvalidOperationException>(delegate { test.Define(new ChildInfo("notFoo", type)); }); Assert.AreEqual(info.OwningType, test); Assert.AreEqual(info.DefiningType, test); Assert.Null(test.GetChildInfo("bar")); }
public async Task <IActionResult> EditChildInfo(string id, ChildInfo child) { if (id != child.Id) { return(BadRequest()); } if (!ChildExists(id)) { return(NotFound()); } var user = await _userManager.Users .FirstOrDefaultAsync(i => i.Id == id); user.FirstName = child.FirstName; user.LastName = child.LastName; user.Email = child.Email; user.UserName = child.UserName; user.BirthDate = child.BirthDate; user.Country = child.Country; user.Province = child.Province; user.City = child.City; user.Street = child.Street; user.PostalCode = child.PostalCode; user.Latitude = child.Latitude; user.Longitude = child.Longitude; user.IsNaughty = child.IsNaughty; try { await _userManager.UpdateAsync(user); } catch (DbUpdateConcurrencyException) { throw; } return(Ok()); }
public void TestRemoveFromParent() { DomNodeType type = new DomNodeType("type"); ChildInfo childInfo = new ChildInfo("child", type); type.Define(childInfo); DomNode parent = new DomNode(type); DomNode child = new DomNode(type); parent.SetChild(childInfo, child); child.RemoveFromParent(); Assert.Null(parent.GetChild(childInfo)); Assert.Null(child.Parent); // Make sure the removed child has a null Parent. http://tracker.ship.scea.com/jira/browse/WWSATF-1336 parent.SetChild(childInfo, child); DomNode newChild = new DomNode(type); parent.SetChild(childInfo, newChild); Assert.Null(child.Parent); Assert.True(newChild.Parent == parent); }
public TestDataValidator() { m_childType = new DomNodeType("child"); m_parentType = new DomNodeType("parent"); m_parentType.Define(new ExtensionInfo <ValidationContext>()); m_parentType.Define(new ExtensionInfo <DataValidator>()); m_childCountRule = new ChildCountRule(2, 3); m_childInfo = new ChildInfo("child", m_childType, true); m_parentType.Define(m_childInfo); m_childInfo.AddRule(m_childCountRule); m_parent = new DomNode(m_parentType); m_parent.InitializeExtensions(); m_validationContext = m_parent.As <ValidationContext>(); m_child1 = new DomNode(m_childType); m_child2 = new DomNode(m_childType); m_child3 = new DomNode(m_childType); m_child4 = new DomNode(m_childType); }
protected DomNodeType RootType; //derives from ChildType public TestValidator() { // define a tree of validation contexts ChildType = new DomNodeType("test"); StringAttrInfo = GetStringAttribute("string"); ChildType.Define(StringAttrInfo); RefAttrInfo = GetRefAttribute("ref"); ChildType.Define(RefAttrInfo); ChildInfo = new ChildInfo("child", ChildType); ChildType.Define(ChildInfo); ChildType.Define(new ExtensionInfo <ValidationContext>()); // define a distinct root type with the validator RootType = new DomNodeType("root"); RootType.BaseType = ChildType; RootType.Define(new ExtensionInfo <Validator>()); AttributeInfo overriddenInfo = GetStringAttribute("string"); RootType.Define(overriddenInfo); IEnumerable <AttributeInfo> attributes = RootType.Attributes; // freezes the types }
public void TestChildListRemove() { DomNodeType type = new DomNodeType("type"); ChildInfo childInfo = new ChildInfo("child", type, true); type.Define(childInfo); DomNode parent = new DomNode(type); IList <DomNode> list = parent.GetChildList(childInfo); DomNode child1 = new DomNode(type); Assert.False(list.Remove(child1)); list.Add(child1); DomNode child2 = new DomNode(type); list.Add(child2); Assert.True(list.Remove(child1)); Utilities.TestSequenceEqual(list, child2); Assert.True(list.Remove(child2)); CollectionAssert.IsEmpty(list); }
public void TestInheritedChildInfo() { ChildInfo info = new ChildInfo("foo", new DomNodeType("foo")); DomNodeType test = new DomNodeType( "test", null, EmptyEnumerable <AttributeInfo> .Instance, new ChildInfo[] { info }, EmptyEnumerable <ExtensionInfo> .Instance); DomNodeType child = new DomNodeType("child"); child.BaseType = test; ChildInfo inherited = child.GetChildInfo("foo"); Assert.AreEqual(inherited.OwningType, test); Assert.AreEqual(inherited.DefiningType, test); Assert.True(inherited.Equivalent(info)); Assert.True(info.Equivalent(inherited)); }
/// <summary> /// Inserts a reference to an object of given type using a transaction. Called by automated scripts during testing.</summary> /// <typeparam name="T">Type of object to insert</typeparam> /// <param name="insertingObject">DomNode that contains inserted object</param> /// <param name="insertionParent">Parent where object is inserted</param> /// <returns>Inserted object</returns> public T InsertAsRef <T>(DomNode insertingObject, DomNode insertionParent) where T : class { ChildInfo childInfo = GetChildInfo(insertionParent, UISchema.UIRefType.Type); EmptyRef emptyRef = new EmptyRef(insertionParent, childInfo); SetInsertionParent(emptyRef); insertingObject.SetAttribute(UISchema.UIType.nameAttribute, typeof(T).Name); DataObject dataObject = new DataObject(new object[] { insertingObject }); ITransactionContext transactionContext = this.As <ITransactionContext>(); transactionContext.DoTransaction( delegate { Insert(dataObject); }, "Scripted Insert Object"); UIRef uiRef = emptyRef.Parent.GetChild(childInfo).As <UIRef>(); DomNode newNode = uiRef.DomNode.As <DomNode>(); return(newNode.As <T>()); }
public void Remove(DomNode parent, DomNode child, ChildInfo chInfo) { NativeObjectAdapter childObject = child.As <NativeObjectAdapter>(); NativeObjectAdapter parentObject = parent.As <NativeObjectAdapter>(); object listIdObj = chInfo.GetTag(NativeAnnotations.NativeElement); if (childObject == null || parentObject == null || listIdObj == null) { return; } uint listId = (uint)listIdObj; uint typeId = (uint)chInfo.DefiningType.GetTag(NativeAnnotations.NativeType); ulong parentId = parentObject.InstanceId; ulong childId = childObject.InstanceId; GameEngine.ObjectRemoveChild(typeId, listId, parentId, childId); if (ManageNativeObjectLifeTime) { GameEngine.DestroyObject(childObject); } }
public void TestChildListIndexer() { DomNodeType type = new DomNodeType("type"); ChildInfo childInfo = new ChildInfo("child", type, true); type.Define(childInfo); DomNode parent = new DomNode(type); IList <DomNode> list = parent.GetChildList(childInfo); DomNode child1 = new DomNode(type); Assert.Throws <IndexOutOfRangeException>(delegate { list[0] = child1; }); list.Add(child1); Assert.AreSame(list[0], child1); DomNode child2 = new DomNode(type); list.Add(child2); Assert.AreSame(list[1], child2); DomNode child3 = new DomNode(type); list[0] = child3; Utilities.TestSequenceEqual(list, child3, child2); // child1 gets removed by set }
/// <summary> /// Measure all childre above each other /// </summary> private Size MeasureChildren(double width, double height) { m_childrenSizes.Clear(); Size s = new Size(); foreach (View child in Children) { Size childSize = child.Measure(width, height, MeasureFlags.IncludeMargins).Request; ChildInfo info = new ChildInfo(child); info.Size = childSize; info.IsParallaxEnabled = GetIsParallaxEnabled(child); info.HorizontalShiftRatio = GetHorizontalShiftRatio(child); info.HorizontalSourceStartOffset = GetHorizontalSourceStartOffset(child); info.HorizontalSourceEndOffset = GetHorizontalSourceEndOffset(child); info.VerticalShiftRatio = GetVerticalShiftRatio(child); info.VerticalSourceStartOffset = GetVerticalSourceStartOffset(child); info.VerticalSourceEndOffset = GetVerticalSourceEndOffset(child); m_childrenSizes.Add(info); if (s.Width < childSize.Width) { s.Width = childSize.Width; } if (s.Height < childSize.Height) { s.Height = childSize.Height; } } return(s); }
public void TestCopy_MultipleNodes() { DomNodeType type = new DomNodeType("type"); ChildInfo info = new ChildInfo("child", type); ChildInfo infoList = new ChildInfo("childList", type, true); type.Define(info); type.Define(infoList); ChildInfo rootInfo = new ChildInfo("root", type, true); DomNode test = new DomNode(type, rootInfo); DomNode child1 = new DomNode(type); test.SetChild(info, child1); DomNode child2 = new DomNode(type); DomNode child3 = new DomNode(type); IList <DomNode> list = test.GetChildList(infoList); list.Add(child2); list.Add(child3); DomNode[] result = DomNode.Copy(new DomNode[] { test }); Assert.AreEqual(result.Length, 1); Assert.True(Equals(result[0], test)); }
/// <summary> /// Inserts 'item' into the set of objects at the desired position. Can only be called /// if CanInsert() returns true.</summary> /// <param name="parent">The object that will become the parent of the inserted object. /// Can be null if the list of objects is a flat list or if the root should be replaced.</param> /// <param name="before">The object that is immediately before the inserted object. /// Can be null to indicate that the inserted item should become the first child.</param> /// <param name="item">The item to be inserted. Consider using Util.ConvertData(item, false) /// to retrieve the final one or more items to be inserted.</param> void IOrderedInsertionContext.Insert(object parent, object before, object item) { DomNode parentDom = parent as DomNode; DomNode beforeDom = before as DomNode; DomNode[] itemsDom = _GetDomNodes(item); ChildInfo childInfo = parentDom.Type.GetChildInfo("node"); IList <DomNode> childList = parentDom.GetChildList(childInfo); if (before == null) { int index = 0; foreach (DomNode node in itemsDom) { childList.Insert(++index, node); } } int beforeIndex = childList.IndexOf(beforeDom); if (beforeIndex == childList.Count - 1) { foreach (DomNode node in itemsDom) { childList.Add(node); } } else { foreach (DomNode node in itemsDom) { childList.Insert(++beforeIndex, node); } } }
/// <summary> /// Checks that the parent's children are in a valid state</summary> /// <param name="parent">Parent DOM node, containing children</param> /// <param name="child">Child DOM node, to add or remove to/from parent</param> /// <param name="childInfo">Child relationship info</param> /// <returns>True if the parent and child are in a valid state with respect to /// each other</returns> public abstract bool Validate(DomNode parent, DomNode child, ChildInfo childInfo);
private DomNode ReadElement(ChildInfo nodeInfo, XmlReader reader) { // handle polymorphism, if necessary var type = GetChildType(nodeInfo.Type, reader); var index = type.Name.LastIndexOf(':'); var typeNs = type.Name.Substring(0, index); var node = new DomNode(type, nodeInfo); // read attributes while (reader.MoveToNextAttribute()) { if (reader.Prefix == string.Empty || reader.LookupNamespace(reader.Prefix) == typeNs) { var attributeInfo = type.GetAttributeInfo(reader.LocalName); if (attributeInfo != null) { var valueString = reader.Value; if (attributeInfo.Type.Type == AttributeTypes.Reference) { // save reference so it can be resolved after all nodes have been read m_nodeReferences.Add(new XmlNodeReference(node, attributeInfo, valueString)); } else { var value = attributeInfo.Type.Convert(valueString); node.SetAttribute(attributeInfo, value); } } } } // add node to map if it has an id if (node.Type.IdAttribute != null) { var id = node.GetId(); if (!string.IsNullOrEmpty(id)) { m_nodeDictionary[id] = node; // don't Add, in case there are multiple DomNodes with the same id } } reader.MoveToElement(); if (!reader.IsEmptyElement) { // read child elements while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { // look up metadata for this element var childInfo = type.GetChildInfo(reader.LocalName); if (childInfo != null) { var childNode = ReadElement(childInfo, reader); if (childNode != null) { // childNode is fully populated sub-tree if (childInfo.IsList) { node.GetChildList(childInfo).Add(childNode); } else { node.SetChild(childInfo, childNode); } } } else { // try reading as an attribute var attributeInfo = type.GetAttributeInfo(reader.LocalName); if (attributeInfo != null) { reader.MoveToElement(); if (!reader.IsEmptyElement) { // read element text while (reader.Read()) { if (reader.NodeType == XmlNodeType.Text) { var value = attributeInfo.Type.Convert(reader.Value); node.SetAttribute(attributeInfo, value); // skip child elements, as this is an attribute value reader.Skip(); break; } if (reader.NodeType == XmlNodeType.EndElement) { break; } } reader.MoveToContent(); } } else { // skip unrecognized element reader.Skip(); // if that takes us to the end of the enclosing element, break if (reader.NodeType == XmlNodeType.EndElement) { break; } } } } else if (reader.NodeType == XmlNodeType.Text) { var attributeInfo = type.GetAttributeInfo(string.Empty); if (attributeInfo != null) { var value = attributeInfo.Type.Convert(reader.Value); node.SetAttribute(attributeInfo, value); } } else if (reader.NodeType == XmlNodeType.EndElement) { break; } } } reader.MoveToContent(); return(node); }
/// <summary> /// Constructor setting parent and ChildInfo</summary> /// <param name="parent">Parent, with no reference child</param> /// <param name="childInfo">Information about reference child</param> public EmptyRef(DomNode parent, ChildInfo childInfo) { Parent = parent; ChildInfo = childInfo; }
private Snapshot TakeSnapshot() { Snapshot s = new Snapshot(); if (IsScrolling) { s._scrollData = new ScrollData(); s._scrollData._offset = _scrollData._offset; s._scrollData._extent = _scrollData._extent; s._scrollData._computedOffset = _scrollData._computedOffset; s._scrollData._viewport = _scrollData._viewport; } s._boolFieldStore = _boolFieldStore; s._areContainersUniformlySized = AreContainersUniformlySized; s._uniformOrAverageContainerSize = UniformOrAverageContainerSize; s._firstItemInExtendedViewportChildIndex = _firstItemInExtendedViewportChildIndex; s._firstItemInExtendedViewportIndex = _firstItemInExtendedViewportIndex; s._firstItemInExtendedViewportOffset = _firstItemInExtendedViewportOffset; s._actualItemsInExtendedViewportCount = _actualItemsInExtendedViewportCount; s._viewport = _viewport; s._itemsInExtendedViewportCount = _itemsInExtendedViewportCount; s._extendedViewport = _extendedViewport; s._previousStackPixelSizeInViewport = _previousStackPixelSizeInViewport; s._previousStackLogicalSizeInViewport = _previousStackLogicalSizeInViewport; s._previousStackPixelSizeInCacheBeforeViewport = _previousStackPixelSizeInCacheBeforeViewport; s._firstContainerInViewport = _firstContainerInViewport; s._firstContainerOffsetFromViewport = _firstContainerOffsetFromViewport; s._expectedDistanceBetweenViewports = _expectedDistanceBetweenViewports; s._bringIntoViewContainer = _bringIntoViewContainer; s._bringIntoViewLeafContainer = _bringIntoViewLeafContainer; ItemContainerGenerator g = Generator as ItemContainerGenerator; List<ChildInfo> list = new List<ChildInfo>(); foreach (UIElement child in RealizedChildren) { ChildInfo info = new ChildInfo(); info._itemIndex = g.IndexFromContainer(child, returnLocalIndex:true); info._desiredSize = child.DesiredSize; info._arrangeRect = child.PreviousArrangeRect; info._inset = (Thickness)child.GetValue(ItemsHostInsetProperty); list.Add(info); } s._realizedChildren = list; return s; }
void IInitializable.Initialize() { m_controlInfo = new ControlInfo("DesignView", "DesignView", StandardControlGroup.CenterPermanent); m_controlHostService.RegisterControl(m_designView.HostControl, m_controlInfo, this); Application.ApplicationExit += delegate { Util3D.Shutdown(); GameEngine.Shutdown(); }; GameEngine.RefreshView += (sender, e) => m_designView.InvalidateViews(); m_gameDocumentRegistry.DocumentAdded += m_gameDocumentRegistry_DocumentAdded; m_gameDocumentRegistry.DocumentRemoved += m_gameDocumentRegistry_DocumentRemoved; string ns = m_schemaLoader.NameSpace; // register GridRenderer on grid child. DomNodeType gridType = m_schemaLoader.TypeCollection.GetNodeType(ns, "gridType"); gridType.Define(new ExtensionInfo <GridRenderer>()); // register NativeGameWorldAdapter on game type. m_schemaLoader.GameType.Define(new ExtensionInfo <NativeDocumentAdapter>()); // parse schema annotation. foreach (DomNodeType domType in m_schemaLoader.TypeCollection.GetNodeTypes()) { var topLevelAnnotations = domType.GetTagLocal <IEnumerable <XmlNode> >(); if (topLevelAnnotations == null) { continue; } // First, go through and interpret the annotations that are not inherited List <NativeAttributeInfo> nativeAttribs = new List <NativeAttributeInfo>(); foreach (XmlNode annot in topLevelAnnotations) { XmlElement elm = annot as XmlElement; if (elm.LocalName == NativeAnnotations.NativeType) { string typeName = elm.GetAttribute(NativeAnnotations.NativeName); domType.SetTag(NativeAnnotations.NativeType, GameEngine.GetObjectTypeId(typeName)); if (domType.IsAbstract == false) { domType.Define(new ExtensionInfo <NativeObjectAdapter>()); } } else if (elm.LocalName == NativeAnnotations.NativeDocumentType) { string typeName = elm.GetAttribute(NativeAnnotations.NativeName); domType.SetTag(NativeAnnotations.NativeDocumentType, GameEngine.GetDocumentTypeId(typeName)); if (domType.IsAbstract == false) { domType.Define(new ExtensionInfo <NativeDocumentAdapter>()); } } } if (domType.GetTag(NativeAnnotations.NativeType) == null) { continue; } uint typeId = (uint)domType.GetTag(NativeAnnotations.NativeType); bool isBoundableType = false; // Now, go through and interpret annotations that can be inheritted from base clases. // Sometimes a native property can be inheritted from a base class. In this model, we // will create a separate "property id" for each concrete class. When a property is // inheritted, the "property ids" for each type in the inheritance chain will be different // and unrelated. foreach (var inherittedType in domType.Lineage) { var annotations = inherittedType.GetTagLocal <IEnumerable <XmlNode> >(); if (annotations == null) { continue; } foreach (XmlNode annot in annotations) { XmlElement elm = annot as XmlElement; if (elm.LocalName == NativeAnnotations.NativeProperty) { // find a prop name and added to the attribute. string nativePropName = elm.GetAttribute(NativeAnnotations.NativeName); string attribName = elm.GetAttribute(NativeAnnotations.Name); uint propId = GameEngine.GetObjectPropertyId(typeId, nativePropName); if (!string.IsNullOrEmpty(attribName)) { AttributeInfo attribInfo = domType.GetAttributeInfo(elm.GetAttribute(NativeAnnotations.Name)); attribInfo.SetTag(NativeAnnotations.NativeProperty, propId); } else { NativeAttributeInfo attribInfo = new NativeAttributeInfo(domType, nativePropName, typeId, propId); nativeAttribs.Add(attribInfo); } if (nativePropName == "Bounds" || nativePropName == "LocalBounds") { isBoundableType = true; } } else if (elm.LocalName == NativeAnnotations.NativeElement) { ChildInfo info = domType.GetChildInfo(elm.GetAttribute(NativeAnnotations.Name)); string name = elm.GetAttribute(NativeAnnotations.NativeName); info.SetTag(NativeAnnotations.NativeElement, GameEngine.GetObjectChildListId(typeId, name)); } else if (elm.LocalName == NativeAnnotations.NativeVis) { using (var transfer = new NativeObjectAdapter.NativePropertyTransfer()) { using (var stream = transfer.CreateStream()) foreach (var a in elm.Attributes) { var attrib = a as XmlAttribute; if (attrib.Name == "geo") { NativeObjectAdapter.PushAttribute( 0, typeof(string), 1, attrib.Value, transfer.Properties, stream); } } GameEngine.SetTypeAnnotation(typeId, "vis", transfer.Properties); } } } } if (nativeAttribs.Count > 0) { domType.SetTag(nativeAttribs.ToArray()); } if (isBoundableType && domType.IsAbstract == false) { domType.Define(new ExtensionInfo <BoundableObject>()); } } // register BoundableObject m_schemaLoader.GameObjectFolderType.Define(new ExtensionInfo <BoundableObject>()); // doesn't have a bound native attributes -- is this really intended?s #region code to handle gameObjectFolder { // This code is fragile and need to be updated whenever // any relevant part of the schema changes. // purpose: // gameObjectFolderType does not exist in C++ // this code will map gameObjectFolderType to gameObjectGroupType. DomNodeType gobFolderType = m_schemaLoader.GameObjectFolderType; DomNodeType groupType = m_schemaLoader.GameObjectGroupType; // map native bound attrib from gameObject to GobFolder NativeAttributeInfo[] nativeAttribs = m_schemaLoader.GameObjectType.GetTag <NativeAttributeInfo[]>(); foreach (var attrib in nativeAttribs) { if (attrib.Name == "Bounds") { gobFolderType.SetTag(new NativeAttributeInfo[] { attrib }); break; } } // map type. // XLE --> Separate GameObjectFolder type from GameObjectGroup type // gobFolderType.Define(new ExtensionInfo<NativeObjectAdapter>()); // gobFolderType.SetTag(NativeAnnotations.NativeType, groupType.GetTag(NativeAnnotations.NativeType)); // map all native attributes of gameObjectGroup to gameFolder foreach (AttributeInfo srcAttrib in groupType.Attributes) { object nativeIdObject = srcAttrib.GetTag(NativeAnnotations.NativeProperty); if (nativeIdObject == null) { continue; } AttributeInfo destAttrib = gobFolderType.GetAttributeInfo(srcAttrib.Name); if (destAttrib == null) { continue; } destAttrib.SetTag(NativeAnnotations.NativeProperty, nativeIdObject); destAttrib.SetTag(NativeAnnotations.MappedAttribute, srcAttrib); } // map native element from gameObjectGroupType to gameObjectFolderType. object gobsId = groupType.GetChildInfo("gameObject").GetTag(NativeAnnotations.NativeElement); foreach (ChildInfo srcChildInfo in gobFolderType.Children) { if (srcChildInfo.IsList) { srcChildInfo.SetTag(NativeAnnotations.NativeElement, gobsId); } } m_schemaLoader.GameType.GetChildInfo("gameObjectFolder").SetTag(NativeAnnotations.NativeElement, gobsId); } #endregion // set up scripting bindings if (m_scriptingService != null) { m_scriptingService.SetVariable("cv", new GUILayer.TweakableBridge()); } }
public override bool Validate(DomNode parent, DomNode child, ChildInfo childInfo) { Validated = true; return(true); }
/// <summary> /// DateSet转IEnumerable /// </summary> /// <typeparam name="T"></typeparam> /// <param name="ds"></param> /// <returns></returns> public static IEnumerable <T> ToCollection <T>(this DataSet ds) where T : new() { if (ds == null || ds.Tables.Count == 0) { return(Enumerable.Empty <T>()); } IDictionary <String, IList> Map = new Dictionary <String, IList>(); IList <T> Parent = new List <T>(); T ParentInstance = new T(); foreach (DataTable dt in ds.Tables) { foreach (DataRow row in dt.Rows) { PropertyInfo[] PropertInfosParent = ParentInstance.GetType().GetProperties(); foreach (PropertyInfo ParentInfo in PropertInfosParent) { if (ParentInfo.PropertyType.IsGenericType) { Type ChildType = ParentInfo.PropertyType.GetGenericArguments().FirstOrDefault(); var ChildInstrance = Activator.CreateInstance(ChildType); PropertyInfo[] PropertInfosChild = ChildInstrance.GetType().GetProperties(); foreach (PropertyInfo ChildInfo in PropertInfosChild) { if (dt.Columns.Contains(ChildInfo.Name)) { if (!ChildInfo.CanWrite) { continue; } object value = row[ChildInfo.Name]; if (value != DBNull.Value) { ChildInfo.SetValue(ChildInstrance, value); } } } var FirstValue = ChildInstrance.GetType().GetProperties().FirstOrDefault().GetValue(ChildInstrance, null); if (FirstValue != null) { Type DynamicList = typeof(List <>).MakeGenericType(ChildType); IList ChildListType = null; if (!Map.ContainsKey(ChildType.FullName)) { ChildListType = Activator.CreateInstance(DynamicList) as IList; Map.Add(ChildType.FullName, ChildListType); } else { ChildListType = Map[ChildType.FullName]; } ChildListType.Add(ChildInstrance); ParentInfo.SetValue(ParentInstance, ChildListType); } } else { if (dt.Columns.Contains(ParentInfo.Name)) { if (!ParentInfo.CanWrite) { continue; } object value = row[ParentInfo.Name]; if (value != DBNull.Value) { ParentInfo.SetValue(ParentInstance, value); } } } } } } Parent.Add(ParentInstance); return(Parent); }
private RenderState CreateRenderStateFromProfileCOMMON() { RenderState rs = null; DomNode profile_COMMON = this.DomNode.GetChild(Schema.effect.profile_COMMONChild); if (profile_COMMON == null) { return(rs); } // Get technique DomNode technique_COMMON = profile_COMMON.GetChild(Schema.profile_COMMON.techniqueChild); if (technique_COMMON == null) { return(rs); } // Get shading profile DomNode shader = technique_COMMON.GetChild(Schema.profile_COMMON_technique.blinnChild) ?? technique_COMMON.GetChild(Schema.profile_COMMON_technique.constantChild) ?? technique_COMMON.GetChild(Schema.profile_COMMON_technique.lambertChild) ?? technique_COMMON.GetChild(Schema.profile_COMMON_technique.phongChild); if (shader == null) { return(rs); } rs = CreateRenderStateDefault(); //<xs:sequence> // <xs:element name="emission" type="common_color_or_texture_type" minOccurs="0"/> // <xs:element name="ambient" type="common_color_or_texture_type" minOccurs="0"/> // <xs:element name="diffuse" type="common_color_or_texture_type" minOccurs="0"/> // <xs:element name="specular" type="common_color_or_texture_type" minOccurs="0"/> // <xs:element name="shininess" type="common_float_or_param_type" minOccurs="0"/> // <xs:element name="reflective" type="common_color_or_texture_type" minOccurs="0"/> // <xs:element name="reflectivity" type="common_float_or_param_type" minOccurs="0"/> // <xs:element name="transparent" type="common_transparent_type" minOccurs="0"/> // <xs:element name="transparency" type="common_float_or_param_type" minOccurs="0"/> // <xs:element name="index_of_refraction" type="common_float_or_param_type" minOccurs="0"/> //</xs:sequence> DomNodeType shaderType = shader.Type; ChildInfo emission = shaderType.GetChildInfo("emission"); ChildInfo ambient = shaderType.GetChildInfo("ambient"); ChildInfo diffuse = shaderType.GetChildInfo("diffuse"); ChildInfo specular = shaderType.GetChildInfo("specular"); ChildInfo shininess = shaderType.GetChildInfo("shininess"); shaderType.GetChildInfo("reflective"); shaderType.GetChildInfo("reflectivity"); shaderType.GetChildInfo("transparent"); ChildInfo transparency = shaderType.GetChildInfo("transparency"); shaderType.GetChildInfo("index_of_refrac"); if (emission != null) { float[] emissionColor = Tools.GetColor(shader.GetChild(emission)); if (emissionColor != null) { rs.EmissionColor = new Vec4F(emissionColor); } } if (ambient != null) { // Surface properties float[] ambientColor = Tools.GetColor(shader.GetChild(ambient)); if (ambientColor != null) { rs.AmbientColor = new Vec4F(ambientColor); } } float transparencyVal = -1.0f; if (transparency != null) { transparencyVal = Tools.GetFloat(shader.GetChild(transparency)); } if (diffuse != null) { float[] diffuseColor = Tools.GetColor(shader.GetChild(diffuse)); if (diffuseColor != null) { if (transparencyVal >= 0.0f) { diffuseColor[3] = transparencyVal; if (transparencyVal < 1.0f) { rs.RenderMode |= RenderMode.Alpha; } } rs.DiffuseColor = new Vec4F(diffuseColor); } } if (specular != null) { float[] specularColor = Tools.GetColor(shader.GetChild(specular)); if (specularColor != null) { rs.SpecularColor = new Vec4F(specularColor); } if (shininess != null) { float shine = Tools.GetFloat(shader.GetChild(shininess)); rs.Shininess = shine; } } if (diffuse == null) { return(rs); } DomNode diffuseChild = shader.GetChild(diffuse); DomNode textureChild = diffuseChild.GetChild(Schema.common_color_or_texture_type.textureChild); if (textureChild == null) { return(rs); } string strTexture = (string)textureChild.GetAttribute(Schema.common_color_or_texture_type_texture.textureAttribute); if (string.IsNullOrEmpty(strTexture)) { return(rs); } IList <DomNode> newParams = profile_COMMON.GetChildList(Schema.profile_COMMON.newparamChild); DomNode sampler = null; foreach (DomNode newParam in newParams) { string sid = newParam.GetAttribute(Schema.common_newparam_type.sidAttribute) as string; if (strTexture == sid) { sampler = newParam; break; } } if (sampler == null) { return(rs); } // sampler2D DomNode sampler2D = sampler.GetChild(Schema.common_newparam_type.sampler2DChild); if (sampler2D == null) { return(rs); } string source = sampler2D.GetAttribute(Schema.fx_sampler2D_common.sourceAttribute) as string; DomNode surfaceParam = null; foreach (DomNode newParam in newParams) { string sid = newParam.GetAttribute(Schema.common_newparam_type.sidAttribute) as string; if (source == sid) { surfaceParam = newParam; break; } } if (surfaceParam == null) { return(rs); } DomNode surface = surfaceParam.GetChild(Schema.common_newparam_type.surfaceChild); if (surface == null) { return(rs); } // init_from //string id = (string)surface.GetAttribute(Schema.fx_surface_common.init_fromAttribute); IList <DomNode> init_fromList = surface.GetChildList(Schema.fx_surface_common.init_fromChild); if (init_fromList.Count > 0) { DomNode init_from = init_fromList[0]; DomNode image = (DomNode)init_from.GetAttribute(Schema.fx_surface_init_from_common.Attribute); Uri uri = (Uri)image.GetAttribute(Schema.image.init_fromAttribute); BindTexture(uri, rs); } return(rs); }
public new IList <T> GetChildList <T>(ChildInfo childInfo) where T : class { return(base.GetChildList <T>(childInfo)); }
private IList<IInfoClass> GetInfoListWithParent() { var child1 = new ChildInfo { AnyChildProperty = ChildValue1 }; var child2 = new ChildInfo { AnyChildProperty = ChildValue2 }; var parent1 = new ParentInfo { AnyParentProperty = ParentValue1 }; var parent2 = new ParentInfo { AnyParentProperty = ParentValue2 }; child1.BaseInfo = parent1; child2.BaseInfo = parent2; return new List<IInfoClass> { child1, child2 }; }
private bool ChildrenMatch(ChildInfo curChild, NodeEvaluationResult curReceived) { return curReceived.StringValue == curChild.ChildText && (curReceived.StringValue == curChild.Repr || curChild.Repr == null); }
private bool ChildrenMatch(ChildInfo curChild, PythonEvaluationResult curReceived) { return curReceived.ChildName == curChild.ChildText && (curReceived.StringRepr == curChild.Repr || curChild.Repr == null) && (Version.Version.Is3x() || (curChild.HexRepr == null || curChild.HexRepr == curReceived.HexRepr));// __hex__ no longer used in 3.x, http://mail.python.org/pipermail/python-list/2009-September/1218287.html }
public override void OnBeginDrag() { if (m_hitRegion == HitRegion.None) { return; } m_cancelDrag = false; Clear(); // cached values. var selectionContext = DesignView.Context.As <ISelectionContext>(); var selection = selectionContext.Selection; var transactionContext = DesignView.Context.As <ITransactionContext>(); IEnumerable <DomNode> rootDomNodes = DomNode.GetRoots(selection.AsIEnumerable <DomNode>()); m_duplicating = Control.ModifierKeys == m_duplicateKey; if (m_duplicating) { List <DomNode> originals = new List <DomNode>(); foreach (DomNode node in rootDomNodes) { ITransformable transformable = node.As <ITransformable>(); if (!CanManipulate(transformable)) { continue; } originals.Add(node); } if (originals.Count > 0) { DomNode[] copies = DomNode.Copy(originals); transactionContext.Begin("Copy And Move".Localize()); List <object> newSelection = new List <object>(); // re-parent copy for (int i = 0; i < copies.Length; i++) { DomNode copy = copies[i]; DomNode original = originals[i]; ChildInfo chInfo = original.ChildInfo; if (chInfo.IsList) { original.Parent.GetChildList(chInfo).Add(copy); } else { original.Parent.SetChild(chInfo, copy); } newSelection.Add(Util.AdaptDomPath(copy)); copy.InitializeExtensions(); } selectionContext.SetRange(newSelection); NodeList.AddRange(copies.AsIEnumerable <ITransformable>()); } } else { foreach (DomNode node in rootDomNodes) { ITransformable transformable = node.As <ITransformable>(); if (!CanManipulate(transformable)) { continue; } NodeList.Add(transformable); } if (NodeList.Count > 0) { transactionContext.Begin("Move".Localize()); } } m_originalValues = new Vec3F[NodeList.Count]; m_originalRotations = new Vec3F[NodeList.Count]; for (int k = 0; k < NodeList.Count; k++) { ITransformable node = NodeList[k]; IManipulatorNotify notifier = node.As <IManipulatorNotify>(); if (notifier != null) { notifier.OnBeginDrag(); } m_originalValues[k] = node.Translation; m_originalRotations[k] = node.Rotation; } }
DomNodeType CreateDOMType(Type clrType) { var nodeType = new DomNodeType(clrType.Name); var propertyDescs = new PropertyDescriptorCollection(null); var properties = clrType.GetProperties(); foreach (var prop in properties) { var propType = prop.PropertyType; AttributeInfo newAttr = null; PropertyDescriptor propDesc = null; if (propType.IsClass && propType != typeof(string)) { ChildInfo newChild = null; object editor = null; var childCLRType = propType.IsArray ? propType.GetElementType() : propType; newChild = new ChildInfo(prop.Name, CreateDOMType(childCLRType), propType.IsArray); nodeType.Define(newChild); if (propType.IsArray && clrType != typeof(SF.Tong.Schema.EditorSocket)) { editor = m_ChildCollectionEditor; } propDesc = new ChildPropertyDescriptor(prop.Name, newChild, "Node", prop.Name, false, editor); } else if (propType.IsEnum) { if (propType.IsArray) { newAttr = new AttributeInfo(prop.Name, AttributeType.StringArrayType); newAttr.AddRule(new StringEnumRule(Enum.GetNames(propType))); } else { newAttr = new AttributeInfo(prop.Name, AttributeType.StringType); newAttr.AddRule(new StringEnumRule(Enum.GetNames(propType))); } } else { if (propType.IsArray) { switch (propType.Name) { case "String": // Consider them as string crc always? newAttr = new AttributeInfo(prop.Name, new AttributeType(AttributeTypes.SingleArray.ToString(), typeof(string[]))); newAttr.AddRule(new StringHashRule()); break; case "int": newAttr = new AttributeInfo(prop.Name, new AttributeType(AttributeTypes.Int32Array.ToString(), typeof(int[]))); break; case "boolean": newAttr = new AttributeInfo(prop.Name, new AttributeType(AttributeTypes.BooleanArray.ToString(), typeof(bool[]))); break; case "Single": newAttr = new AttributeInfo(prop.Name, new AttributeType(AttributeTypes.SingleArray.ToString(), typeof(float[]))); break; default: throw new NotSupportedException("Not supported data type for DOM type gen:" + prop.PropertyType.Name); } } else { switch (propType.Name) { case "String": // Consider them as string crc always? newAttr = new AttributeInfo(prop.Name, AttributeType.StringType); newAttr.AddRule(new StringHashRule()); break; case "int": newAttr = new AttributeInfo(prop.Name, AttributeType.IntType); break; case "boolean": newAttr = new AttributeInfo(prop.Name, AttributeType.BooleanType); break; case "Single": newAttr = new AttributeInfo(prop.Name, AttributeType.FloatType); break; default: throw new NotSupportedException("Not supported data type for DOM type gen:" + prop.PropertyType.Name); } } } if (newAttr != null) { propDesc = new AttributePropertyDescriptor(prop.Name, newAttr, "Node", prop.Name, false); nodeType.Define(newAttr); } if (propDesc != null) { propertyDescs.Add(propDesc); } } nodeType.SetTag(propertyDescs); return(nodeType); }
void Awake() { carController = transform.root.GetComponent<CarController>(); childInfo = transform.GetChild(0).GetComponent<ChildInfo>(); }
public void Test() { XmlSchemaTypeLoader loader = new XmlSchemaTypeLoader(); loader.SchemaResolver = new ResourceStreamResolver( Assembly.GetExecutingAssembly(), "UnitTests.Atf/Resources"); loader.Load("testComplexTypes.xsd"); DomNodeType abstractType = loader.GetNodeType("test:abstractType"); Assert.IsTrue(abstractType != null); Assert.IsTrue(abstractType.IsAbstract); DomNodeType complexType1 = loader.GetNodeType("test:complexType1"); Assert.IsTrue(complexType1 != null); Assert.IsTrue(!complexType1.IsAbstract); Assert.IsTrue(complexType1.BaseType == abstractType); //Assert.IsTrue(complexType1.FindAnnotation("annotation") != null); //Assert.IsTrue(complexType1.FindAnnotation("annotation", "attr1") != null); DomNodeType complexType2 = loader.GetNodeType("test:complexType2"); Assert.IsTrue(complexType2 != null); Assert.IsTrue(!complexType2.IsAbstract); AttributeInfo attr1 = complexType2.GetAttributeInfo("attr1"); Assert.IsTrue(attr1 != null); Assert.IsTrue(attr1.DefaultValue.Equals(1)); //Assert.IsTrue(attr1.FindAnnotation("annotation") != null); AttributeInfo attr2 = complexType2.GetAttributeInfo("attr2"); Assert.IsTrue(attr2 != null); Assert.IsTrue(attr2.DefaultValue.Equals(2)); DomNodeType complexType3 = loader.GetNodeType("test:complexType3"); Assert.IsTrue(complexType3 != null); Assert.IsTrue(!complexType3.IsAbstract); Assert.IsTrue(complexType3.BaseType == complexType2); AttributeInfo attr3 = complexType3.GetAttributeInfo("attr3"); Assert.IsTrue(attr3 != null); ChildInfo elem1 = complexType3.GetChildInfo("elem1"); Assert.IsTrue(elem1 != null); Assert.IsTrue(elem1.Type == complexType1); //Assert.IsTrue(elem1.FindAnnotation("annotation") != null); ChildInfo elem2 = complexType3.GetChildInfo("elem2"); Assert.IsTrue(elem2 != null); Assert.IsTrue(elem2.Type == complexType1); Assert.IsTrue(MinMaxCheck(elem2, 1, 3)); ChildInfo elem3 = complexType3.GetChildInfo("elem3"); Assert.IsTrue(elem3 != null); //because a sequence of simple types becomes a sequence of child DomNodes attr3 = complexType3.GetAttributeInfo("elem3"); Assert.IsTrue(attr3 == null); //because a sequence of simple types becomes a sequence of child DomNodes DomNode node3 = new DomNode(complexType3); DomNode elem3Child1 = new DomNode(elem3.Type); AttributeInfo elem3ValueAttributeInfo = elem3.Type.GetAttributeInfo(string.Empty); elem3Child1.SetAttribute(elem3ValueAttributeInfo, 1); DomNode elem3Child2 = new DomNode(elem3.Type); elem3Child2.SetAttribute(elem3ValueAttributeInfo, 1); DomNode elem3Child3 = new DomNode(elem3.Type); elem3Child3.SetAttribute(elem3ValueAttributeInfo, 1); node3.GetChildList(elem3).Add(elem3Child1); node3.GetChildList(elem3).Add(elem3Child2); node3.GetChildList(elem3).Add(elem3Child3); IList <DomNode> node3Children = node3.GetChildList(elem3); Assert.IsTrue((int)node3Children[0].GetAttribute(elem3ValueAttributeInfo) == 1); Assert.IsTrue((int)node3Children[1].GetAttribute(elem3ValueAttributeInfo) == 1); Assert.IsTrue((int)node3Children[2].GetAttribute(elem3ValueAttributeInfo) == 1); // Update on 8/16/2011. DomXmlReader would not be able to handle a sequence of elements // of a simple type like this. When reading, each subsequent element's value would be // used to set the attribute on the DomNode, overwriting the previous one. So, since // this behavior of converting more than one element of a simple type into an attribute // array was broken, I want to change this unit test that I wrote and make sequences of // elements of simple types into a sequence of DomNode children with a value attribute. // (A value attribute means an attribute whose name is "".) --Ron //ChildInfo elem3 = complexType3.GetChildInfo("elem3"); //Assert.IsTrue(elem3 == null); //because a sequence of simple types becomes an attribute //attr3 = complexType3.GetAttributeInfo("elem3"); //Assert.IsTrue(attr3 != null); //because a sequence of simple types becomes an attribute //DomNode node3 = new DomNode(complexType3); //object attr3Obj = node3.GetAttribute(attr3); //Assert.IsTrue( // attr3Obj is int && // (int)attr3Obj == 0); //the default integer //node3.SetAttribute(attr3, 1); //attr3Obj = node3.GetAttribute(attr3); //Assert.IsTrue( // attr3Obj is int && // (int)attr3Obj == 1); //node3.SetAttribute(attr3, new int[] { 1, 2, 3 }); //attr3Obj = node3.GetAttribute(attr3); //Assert.IsTrue( // attr3Obj is int[] && // ((int[])attr3Obj)[2]==3); DomNodeType complexType4 = loader.GetNodeType("test:complexType4"); Assert.IsTrue(complexType4 != null); Assert.IsTrue(!complexType4.IsAbstract); attr1 = complexType4.GetAttributeInfo("attr1"); Assert.IsTrue(attr1 != null); elem1 = complexType4.GetChildInfo("elem1"); Assert.IsTrue(elem1 != null); Assert.IsTrue(elem1.Type == complexType3); Assert.IsTrue(MinMaxCheck(elem1, 1, 1)); DomNodeType complexType5 = loader.GetNodeType("test:complexType5"); Assert.IsTrue(complexType5 != null); Assert.IsTrue(!complexType5.IsAbstract); elem1 = complexType5.GetChildInfo("elem1"); Assert.IsTrue(elem1 != null); Assert.IsTrue(elem1.Type == abstractType); Assert.IsTrue(MinMaxCheck(elem1, 1, Int32.MaxValue)); DomNode node5 = new DomNode(complexType5); elem2 = complexType5.GetChildInfo("elem2"); DomNode node2 = new DomNode(complexType2); node5.SetChild(elem2, node2); node5.SetChild(elem2, null); node3 = new DomNode(complexType3); elem3 = complexType5.GetChildInfo("elem3"); node5.SetChild(elem3, node3); //The following should violate xs:choice, but we don't fully support this checking yet. //ExceptionTester.CheckThrow<InvalidOperationException>(delegate { node5.AddChild(elem2, node2); }); DomNodeType complexType6 = loader.GetNodeType("test:complexType6"); Assert.IsTrue(complexType6 != null); Assert.IsTrue(!complexType6.IsAbstract); elem1 = complexType6.GetChildInfo("elem1"); Assert.IsTrue(elem1 != null); Assert.IsTrue(elem1.Type == abstractType); Assert.IsTrue(MinMaxCheck(elem1, 1, Int32.MaxValue)); elem2 = complexType6.GetChildInfo("elem2"); Assert.IsTrue(elem2 != null); Assert.IsTrue(elem2.Type == complexType2); Assert.IsTrue(MinMaxCheck(elem2, 1, Int32.MaxValue)); //DomNodeType complexType7 = loader.GetNodeType("test:complexType7"); //Assert.IsTrue(complexType7 != null); //Assert.IsTrue(!complexType7.IsAbstract); //AttributeInfo attrSimpleSequence = complexType7.GetAttributeInfo("elemSimpleSequence"); //Assert.IsTrue(attrSimpleSequence == null); //because a sequence of simple types becomes a sequence of child DomNodes //ChildInfo elemSimpleSequence = complexType7.GetChildInfo("elemSimpleSequence"); //Assert.IsTrue(elemSimpleSequence != null); //because a sequence of simple types becomes a sequence of child DomNodes //DomNode node7 = new DomNode(complexType7); //object attrObj7 = node7.GetAttribute(attrSimpleSequence); //Assert.IsTrue( // attrObj7 is float[] && // ((float[])attrObj7)[0] == 0 && // ((float[])attrObj7)[1] == 0 && // ((float[])attrObj7)[2] == 0); //the default vector //float[][] newSequence = //{ // new float[] {1, 2, 3}, // new float[] {4, 5, 6}, // new float[] {7, 8, 9} //}; //node7.SetAttribute(attrSimpleSequence, newSequence); //attrObj7 = node7.GetAttribute(attrSimpleSequence); //Assert.IsTrue(ArraysEqual(attrObj7, newSequence)); }
void InitializeProperties() { m_PropertyInfos.Clear(); foreach (var enumValueObj in Enum.GetValues(typeof(SF.Tong.Schema.PropertyType))) { var enumValue = (SF.Tong.Schema.PropertyType)enumValueObj; AttributeInfo newAttr = null, newListAttr = null; DomNodeType childNodeType = null; object editor = null; TypeConverter converter = null; switch (enumValue) { //case SF.Tong.Schema.PropertyType.Event: // newAttr = new AttributeInfo(enumValue.ToString(), AttributeType.BooleanType); // newListAttr = new AttributeInfo(enumValue.ToString() + "[]", AttributeType.BooleanArrayType); // break; case SF.Tong.Schema.PropertyType.Boolean: newAttr = new AttributeInfo(enumValue.ToString(), AttributeType.BooleanType); newListAttr = new AttributeInfo(enumValue.ToString() + "[]", AttributeType.BooleanArrayType); break; case SF.Tong.Schema.PropertyType.@Int: newAttr = new AttributeInfo(enumValue.ToString(), AttributeType.IntType); newListAttr = new AttributeInfo(enumValue.ToString() + "[]", AttributeType.IntArrayType); break; //case SF.Tong.Schema.PropertyType.@float: // newAttr = new AttributeInfo(enumValue.ToString(), AttributeType.FloatType); // newListAttr = new AttributeInfo(enumValue.ToString() + "[]", AttributeType.FloatArrayType); // break; //case SF.Tong.Schema.PropertyType.@double: // newAttr = new AttributeInfo(enumValue.ToString(), AttributeType.DoubleType); // newListAttr = new AttributeInfo(enumValue.ToString() + "[]", AttributeType.DoubleArrayType); // break; case SF.Tong.Schema.PropertyType.@Decimal: newAttr = new AttributeInfo(enumValue.ToString(), AttributeType.DecimalType); newListAttr = new AttributeInfo(enumValue.ToString() + "[]", AttributeType.DecimalArrayType); break; case SF.Tong.Schema.PropertyType.@String: newAttr = new AttributeInfo(enumValue.ToString(), AttributeType.StringType); newListAttr = new AttributeInfo(enumValue.ToString() + "[]", AttributeType.StringArrayType); break; case SF.Tong.Schema.PropertyType.FixedString: newAttr = new AttributeInfo(enumValue.ToString(), AttributeType.StringType); newAttr.AddRule(new StringHashRule()); newListAttr = new AttributeInfo(enumValue.ToString() + "[]", AttributeType.StringArrayType); newListAttr.AddRule(new StringHashRule()); break; case SF.Tong.Schema.PropertyType.Vector3: newAttr = new AttributeInfo(enumValue.ToString(), new AttributeType(enumValue.ToString(), typeof(float[]), 3)); editor = new Sce.Atf.Controls.PropertyEditing.NumericTupleEditor(typeof(float), new string[] { "x", "y", "z" }); break; case SF.Tong.Schema.PropertyType.Socket: childNodeType = CreateDOMType(typeof(SF.Tong.Schema.EditorSocket)); socketType.Type = childNodeType; // cache for global use break; case SF.Tong.Schema.PropertyType.Signal: newAttr = new AttributeInfo(enumValue.ToString(), AttributeType.NameStringType); newListAttr = new AttributeInfo(enumValue.ToString() + "[]", AttributeType.NameStringType); break; case SF.Tong.Schema.PropertyType.File: case SF.Tong.Schema.PropertyType.Asset: // TODO: add new types for them case SF.Tong.Schema.PropertyType.Enum: // We don't actually use Enum here. just assign string for now newAttr = new AttributeInfo(enumValue.ToString(), AttributeType.StringType); newListAttr = new AttributeInfo(enumValue.ToString() + "[]", AttributeType.StringArrayType); break; case SF.Tong.Schema.PropertyType.@Object: newAttr = new AttributeInfo(enumValue.ToString(), AttributeType.DomNodeRefType); newListAttr = new AttributeInfo(enumValue.ToString() + "[]", AttributeType.DomNodeRefArrayType); break; case SF.Tong.Schema.PropertyType.@ObjectType: newAttr = new AttributeInfo(enumValue.ToString(), AttributeType.StringType); newListAttr = new AttributeInfo(enumValue.ToString() + "[]", AttributeType.StringArrayType); editor = m_ObjectTypeEditor; converter = m_ObjectTypeConverter; break; default: throw new InvalidDataException("There is a not-handled property type"); } if (newAttr != null) { var propInfo = new PropertyInformation() { AttributeInfo = newAttr, ListAttributeInfo = newListAttr, ChildInfo = null, Editor = editor, Converter = converter, }; m_PropertyInfos.Add(propInfo); } else if (childNodeType != null) { ChildInfo newChild = new ChildInfo(enumValue.ToString(), childNodeType); var propInfo = new PropertyInformation() { AttributeInfo = null, ListAttributeInfo = null, ChildInfo = newChild, Editor = null, Converter = null, }; m_PropertyInfos.Add(propInfo); } else { Outputs.WriteLine(OutputMessageType.Warning, "Invalid property {0}", enumValue.ToString()); } } }
private ChildInfo[] GetSetChildren(ChildInfo items) { if (this is DebuggerTestsIpy) { return new ChildInfo[] { new ChildInfo("Count", null), items }; } return new[] { items }; }
public new T GetChild <T>(ChildInfo childInfo) where T : class { return(base.GetChild <T>(childInfo)); }
ChildInfo FillDirRec(Gtk.TreeIter iter, IWorkspaceFileObject item, HashSet <string> itemFiles, HashSet <string> knownPaths, FilePath dir, bool forceSet) { ChildInfo cinfo = ChildInfo.AllSelected; bool hasChildren = false; foreach (string sd in knownSubdirs) { if (dir == item.BaseDirectory.Combine(sd)) { forceSet = true; break; } } TreeIter dit; if (!iter.Equals(TreeIter.Zero)) { dit = store.AppendValues(iter, false, DesktopService.GetPixbufForFile(dir, IconSize.Menu), dir.FileName.ToString(), dir.ToString()); fileList.ExpandRow(store.GetPath(iter), false); } else { dit = store.AppendValues(false, DesktopService.GetPixbufForFile(dir, IconSize.Menu), dir.FileName.ToString(), dir.ToString()); } paths [dir] = dit; foreach (string file in Directory.GetFiles(dir)) { string path = System.IO.Path.GetFileName(file); Gdk.Pixbuf pix = DesktopService.GetPixbufForFile(file, IconSize.Menu); bool active = itemFiles.Contains(file); string color = null; if (!active) { pix = ImageService.MakeTransparent(pix, 0.5); color = "dimgrey"; } else { cinfo |= ChildInfo.HasProjectFiles; } active = active || forceSet || knownPaths.Contains(file); if (!active) { cinfo &= ~ChildInfo.AllSelected; } else { cinfo |= ChildInfo.SomeSelected; } paths [file] = store.AppendValues(dit, active, pix, path, file, color); if (!hasChildren) { hasChildren = true; fileList.ExpandRow(store.GetPath(dit), false); } } foreach (string cdir in Directory.GetDirectories(dir)) { hasChildren = true; ChildInfo ci = FillDirRec(dit, item, itemFiles, knownPaths, cdir, forceSet); if ((ci & ChildInfo.AllSelected) == 0) { cinfo &= ~ChildInfo.AllSelected; } cinfo |= ci & (ChildInfo.SomeSelected | ChildInfo.HasProjectFiles); } if ((cinfo & ChildInfo.AllSelected) != 0 && hasChildren) { store.SetValue(dit, 0, true); } if ((cinfo & ChildInfo.HasProjectFiles) == 0) { Gdk.Pixbuf pix = DesktopService.GetPixbufForFile(dir, IconSize.Menu); pix = ImageService.MakeTransparent(pix, 0.5); store.SetValue(dit, 1, pix); store.SetValue(dit, 4, "dimgrey"); } if ((cinfo & ChildInfo.SomeSelected) != 0 && (cinfo & ChildInfo.AllSelected) == 0) { fileList.ExpandRow(store.GetPath(dit), false); } else { fileList.CollapseRow(store.GetPath(dit)); } return(cinfo); }
public new void SetChild(ChildInfo childInfo, IAdaptable value) { base.SetChild(childInfo, value); }