void AssertSorted(DynamicPropertyCollection c) { var items = c.ToArray(); Assert.AreEqual(items[0].Name, "A"); Assert.AreEqual(items[1].Name, "B"); Assert.AreEqual(items[2].Name, "C"); }
/// <summary>s /// Creates an instance of the class /// </summary> internal DynamicClass(DynamicAssembly parent) { Parent = parent; Usings = new DynamicUsingsCollection(); Interfaces = new DynamicInterfaceCollection(); Properties = new DynamicPropertyCollection(); Methods = new DynamicMethodCollection(); }
public void Add() { var c = new DynamicPropertyCollection(); Assert.IsTrue(string.Compare("A", "B") < 0); Assert.IsTrue(string.Compare("B", "C") < 0); //以 A 打头 c.Add(new DynamicProperty("A", typeof(string))); c.Add(new DynamicProperty("B", typeof(string))); c.Add(new DynamicProperty("C", typeof(string))); AssertSorted(c); c = new DynamicPropertyCollection(); c.Add(new DynamicProperty("A", typeof(string))); c.Add(new DynamicProperty("C", typeof(string))); c.Add(new DynamicProperty("B", typeof(string))); //=================================== //以 B 打头 c = new DynamicPropertyCollection(); c.Add(new DynamicProperty("B", typeof(string))); c.Add(new DynamicProperty("A", typeof(string))); c.Add(new DynamicProperty("C", typeof(string))); AssertSorted(c); c = new DynamicPropertyCollection(); c.Add(new DynamicProperty("B", typeof(string))); c.Add(new DynamicProperty("C", typeof(string))); c.Add(new DynamicProperty("A", typeof(string))); AssertSorted(c); //============================================= //以 C 打头 c = new DynamicPropertyCollection(); c.Add(new DynamicProperty("C", typeof(string))); c.Add(new DynamicProperty("B", typeof(string))); c.Add(new DynamicProperty("A", typeof(string))); AssertSorted(c); c = new DynamicPropertyCollection(); c.Add(new DynamicProperty("C", typeof(string))); c.Add(new DynamicProperty("A", typeof(string))); c.Add(new DynamicProperty("B", typeof(string))); AssertSorted(c); }
void IScene_PropertyChanged(object sender, PropertyChangedArgs e) { // since this is not only for components, but also for its base class, it should be moved to a more central place if (!(e._component is DynamicPropertyCollection)) { return; } DynamicPropertyCollection comp = (DynamicPropertyCollection)e._component; DynamicProperty prop = comp.GetProperty(e._propertyName); comp.OnValueChanged(prop); }
void MigrateLineFollowerEntityProperties(DynamicPropertyCollection entityProps, ShapeComponent component) { component.SetPropertyValue("Model_AnimationName", entityProps.GetPropertyValue("AnimationName", false), false); component.SetPropertyValue("Path_Key", entityProps.GetPropertyValue("PathKey", false), false); component.SetPropertyValue("Path_NumberSteps", entityProps.GetPropertyValue("PathSteps", false), false); component.SetPropertyValue("Path_TriggerDistance", entityProps.GetPropertyValue("TriggerDistance", false), false); component.SetPropertyValue("Path_InitialOffset", entityProps.GetPropertyValue("InitialOffset", false), false); component.SetPropertyValue("Model_DeltaRotation", entityProps.GetPropertyValue("DeltaRotation", false), false); component.SetPropertyValue("Model_GroundOffset", entityProps.GetPropertyValue("ModelOffset", false), false); component.SetPropertyValue("Model_CapsuleHeight", entityProps.GetPropertyValue("CapsuleHeight", false), false); component.SetPropertyValue("Model_CapsuleRadius", entityProps.GetPropertyValue("CapsuleRadius", false), false); component.SetPropertyValue("Debug_DisplayBoxes", entityProps.GetPropertyValue("DisplayBoxes", false), false); component.SetPropertyValue("Debug_RenderMesh", entityProps.GetPropertyValue("DebugRendering", false), false); }
public override object GetData(ITabContext context) { TabSection episerverTab = Plugin.Create("Section", "Content"); PageData currentPageData = EPiServerDataFactory.GetPageData(context.GetHttpContext().Request.RawUrl); TabSection pageData = new TabSection("Property", "Value"); pageData.AddRow().Column("Name").Column(currentPageData.Name); pageData.AddRow().Column("Page Name").Column(currentPageData.PageName); pageData.AddRow().Column("Page Type").Column(currentPageData.PageTypeName); pageData.AddRow() .Column("Start Publish") .Column(currentPageData.StartPublish.ToString(CultureInfo.InvariantCulture)); pageData.AddRow() .Column("Stop Publish") .Column(currentPageData.StopPublish.ToString(CultureInfo.InvariantCulture)); episerverTab.Section("Page Information", pageData); // Possible child page types? // version PageReference currentPageRef = EPiServerDataFactory.GetPageReference( context.GetHttpContext().Request.RawUrl); DynamicPropertyCollection dynprops = DynamicProperty.ListForPage(currentPageRef); TabSection dynpropData = new TabSection(); foreach (DynamicProperty dynprop in dynprops) { PropertyData prop = dynprop.PropertyValue; dynpropData.AddRow().Column(prop.Name).Column(prop.IsNull ? "null" : prop.Value.ToString()); } episerverTab.Section("Dynamic Properties", dynpropData); TabSection langData = new TabSection("Property", "Value"); langData.AddRow().Column("Page Language").Column(currentPageData.Language); langData.AddRow().Column("Is Master Language").Column(currentPageData.IsMasterLanguageBranch ? "Yes" : "No"); langData.AddRow().Column("Page Languages").Column(currentPageData.PageLanguages); episerverTab.Section("Languages", langData); return(episerverTab); }
public void TestEntityPropertySerialization() { try { const string TEST_SCENENAME = "TestEntityPropertySerialization"; // setup new test project/scene TestManager.Helpers.CreateTestScene(TEST_SCENENAME); EditorProject project = EditorApp.Project; // create an entity shape EditorManager.GetShapeCreatorPluginByName("Entity").ExecutePlugin(); ShapeBase entityShape = EditorManager.Scene.ActiveLayer.Root.ChildCollection[0]; string projectFile = project.PathName; int numCreatedShapes = CountShapeInstances(project.Scene); // cause engine view to refresh (to see that rendering the shapes doesn't cause a crash) TestManager.Helpers.ProcessEvents(); // close map project.Save(); project.Close(); // reload map project = EditorManager.ProjectFactory.CreateInstance(null) as EditorProject; Assert.IsNotNull(project); project.Load(projectFile); EditorManager.Project = project; bool bResult = project.OpenScene(TEST_SCENENAME); Assert.IsTrue(bResult); // verify that EntityProperty type is part of the active EntityClassManager assembly entityShape = EditorManager.Scene.ActiveLayer.Root.ChildCollection[0]; DynamicPropertyCollection entityProperties = (DynamicPropertyCollection)entityShape.GetType().InvokeMember("EntityProperties", BindingFlags.GetProperty, null, entityShape, new object[] {}); Assert.IsTrue(EditorManager.EngineManager.EntityClassManager.Exists(entityProperties.CollectionType.UniqueName)); TestManager.Helpers.CloseTestProject(); } catch (Exception ex) { EditorManager.DumpException(ex, true); throw ex; } }
void MigratePhysXEntityProperties(DynamicPropertyCollection entityProps, ShapeComponent havok) { { // Havok: "Dynamic/Keyframed/Fixed/Sphere Inertia/Box Inertia/Thin Box Inertia/Character" // PhysX: "Dynamic/Static/Kinematic" string sValue = (string)entityProps.GetPropertyValue("m_ePhysicsType", false); // since it is an enum, we get it as a string if (sValue == "Static") { sValue = "Fixed"; } else if (sValue == "Kinematic") { sValue = "Keyframed"; } havok.SetPropertyValue("Havok_MotionType", sValue, false); } { // Havok: "Box/Sphere/Convex Hull/File/Capsule/Cylinder/Mesh" // PhysX: "Box/Sphere/File/Hull/Mesh" string sValue = (string)entityProps.GetPropertyValue("m_ePhysicsGeom", false); // since it is an enum, we get it as a string if (sValue == "Hull" || sValue == "File") { sValue = "Convex Hull"; // since PhysXFile + Havok_FileResourceName does not match, convert "File" to "Convex Hull" } havok.SetPropertyValue("Shape_Type", sValue, false); } // mass of zero is not legal for dynamic rigid bodies in Havok. Furthermore, very old versions of the entity class // did not have a mass property, so additionally check whether the property is there object fValue = entityProps.GetPropertyValue("m_fMass", false); if ((fValue is float) && ((float)fValue) > 0.0f) { havok.SetPropertyValue("Havok_Mass", fValue); } havok.SetPropertyValue("Shape_Radius", entityProps.GetPropertyValue("m_fRadius", false)); havok.SetPropertyValue("Shape_BoxSize", entityProps.GetPropertyValue("m_bboxSize", false)); havok.SetPropertyValue("Shape_PivotOffset", entityProps.GetPropertyValue("m_bLocalOffset", false)); havok.SetPropertyValue("Debug_Render", entityProps.GetPropertyValue("DebugRendering", false)); }
private IDynamic Parse(string name, IParsingSourceStream sourceStream) { IDynamicPropertyCollection Properties = new DynamicPropertyCollection(); sourceStream.ReadLine(); string Line = sourceStream.Line; int Indentation = -1; bool UseTab = false; while (Line != null) { IDynamicProperty Property = Parse(sourceStream, ref Line, ref Indentation, ref UseTab); Properties.Add(Property); } string FileName = ParserDomain.ToCSharpName(sourceStream, name + "PageDynamic"); string XamlPageName = ParserDomain.ToXamlName(sourceStream, name, "Page"); return(new Dynamic(name, FileName, XamlPageName, Properties)); }
/// <summary> /// Called when deserializing /// </summary> /// <param name="info"></param> /// <param name="context"></param> protected EntityShape(SerializationInfo info, StreamingContext context) : base(info, context) { _entityClass = info.GetString( "_entityClass" ); _modelFile = info.GetString( "_modelFile" ); // load entity properties object entityProps = (object) info.GetValue( "_entityProperties", typeof(object) ); _entityProperties = entityProps as DynamicPropertyCollection; // Store the old property collection data in a member variable (when loading old scene files). // We'll migrate the property values in the OnDeserialization when all nested properties are fully loaded. if (_entityProperties == null) { _oldEntityProperties = entityProps as CloneableBase; UpdateEntityProperties(true); //_entityProperties = EditorManager.EngineManager.EntityClassManager.CreateCollection(this,_entityClass); } if (SerializationHelper.HasElement(info,"_bCastStaticShadows")) _bCastStaticShadows = info.GetBoolean("_bCastStaticShadows"); if (SerializationHelper.HasElement(info,"_bCastDynamicShadows")) _bCastDynamicShadows = info.GetBoolean("_bCastDynamicShadows"); if (SerializationHelper.HasElement(info,"_vLightGridOfs")) _vLightGridOfs = (Vector3F)info.GetValue("_vLightGridOfs", typeof(Vector3F)); if (SerializationHelper.HasElement(info,"_iVisibleBitmask")) _iVisibleBitmask = (FlagsInt32_e)info.GetValue("_iVisibleBitmask", typeof(FlagsInt32_e)); if (SerializationHelper.HasElement(info,"_iLightInfluenceBitmask")) _iLightInfluenceBitmask = (FlagsInt32_e)info.GetValue("_iLightInfluenceBitmask", typeof(FlagsInt32_e)); // if (SerializationHelper.HasElement(info,"_fLightmapTiling")) // _fLightmapTiling = info.GetSingle("_fLightmapTiling"); if (SerializationHelper.HasElement(info,"_ambientColor")) _ambientColor = (Color)info.GetValue("_ambientColor", typeof(Color)); if (SerializationHelper.HasElement(info, "_farClipDistance")) _farClipDistance = info.GetSingle("_farClipDistance"); if (SerializationHelper.HasElement(info, "_nearClipDistance")) _nearClipDistance = info.GetSingle("_nearClipDistance"); if (SerializationHelper.HasElement(info, "_renderOrderPriority")) _renderOrderPriority = info.GetSByte("_renderOrderPriority"); if (SerializationHelper.HasElement(info, "_classDefTemplate")) _classDefTemplate = info.GetString("_classDefTemplate"); if (SerializationHelper.HasElement(info, "_copySource")) _copySource = (EntityShape)info.GetValue("_copySource", typeof(EntityShape)); if (SerializationHelper.HasElement(info, "_customMaterialSetName")) _customMaterialSetName = info.GetString("_customMaterialSetName"); }
void UpdateEntityProperties(bool bCreateInstance) { DynamicPropertyManager manager = EditorManager.EngineManager.EntityClassManager; // definition from XML or entity class? string relevantTemplate = _classDefTemplate; if (string.IsNullOrEmpty(relevantTemplate)) relevantTemplate = _entityClass; else { // XML template not yet in the dynamic type manager? if (!manager.Exists(_classDefTemplate)) { DynamicPropertyCollectionType newType = manager.CreateNewType(_classDefTemplate, DynamicPropertyCollectionType.DynamicPropertyCollectionFlags_e.None); LoadPropertyTemplateFile(_classDefTemplate, newType); manager.AddCollectionType(newType); } } if (!bCreateInstance) return; // recreate the dynamic properties try { _entityProperties = manager.CreateCollection(this, relevantTemplate); } catch { EditorManager.ShowMessageBox("Could not create specific entity properties.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Serialization helper function /// </summary> public override void OnDeserialization() { base.OnDeserialization(); UpdateEntityProperties(false); // create collection type for XML files, no instance // Migrate the old property values to the new collection (when loading old scene files) if (_oldEntityProperties != null) { _entityProperties.CopyValuesFromOldCollection(_oldEntityProperties); } else { // migrate entity key to new style. Do this before migrating the collection as the key won't be in tehre anymore if (_entityProperties != null && _entityProperties.GetProperty("entityKey") != null) { _objectKey = _entityProperties.GetPropertyValue("entityKey", false) as string; } // recreate entity properties with latest entity class manager (take over old values) _entityProperties = EditorManager.EngineManager.EntityClassManager.CreateMigratedCollection(_entityProperties); if (_entityProperties != null) _entityProperties.Owner = this; } }
/// <summary> /// finalize the effect properties /// </summary> public override void OnDeserialization() { // migrate the properties to get latest attributes etc. if (_effectProperties!=null) //FIX #14249: There are no properties if no EffectClass has been selected _effectProperties = PropertyManager.CreateMigratedCollection(_effectProperties); base.OnDeserialization (); }
/// <summary> /// Called when deserializing /// </summary> /// <param name="info"></param> /// <param name="context"></param> protected PostProcessingShape(SerializationInfo info, StreamingContext context) : base(info, context) { _effectClassName = info.GetString("_effectClassName"); // cache the class properties ClassProperties = EngineInstancePostProcessingEffect.GetClassPropertyType(PropertyManager, _effectClassName); bool _bActive = info.GetBoolean("_bActive"); _effectProperties = (DynamicPropertyCollection)info.GetValue( "_effectProperties", typeof(DynamicPropertyCollection) ); if (SerializationHelper.HasElement(info,"_key")) _key = info.GetString("_key"); if (_bActive) Activate(); }
protected UIShapeBase(SerializationInfo info, StreamingContext context) : base(info, context) { m_PosX = info.GetSingle("PosX"); m_PosY = info.GetSingle("PosY"); m_SizeX = info.GetSingle("SizeX"); m_SizeY = info.GetSingle("SizeY"); m_Order = info.GetInt32("Order"); m_TabOrder = info.GetInt32("TabOrder"); m_ClientBorder = info.GetSingle("ClientBorder"); m_UseCaching = info.GetBoolean("UseCaching"); m_TooltipText = info.GetString("TooltipText"); m_Script = info.GetString("Script"); object entityProps = (object)info.GetValue("_uiProperties", typeof(object)); _uiProperties = entityProps as DynamicPropertyCollection; if (_uiProperties == null) { _oldEntityProperties = entityProps as CloneableBase; //_entityProperties = EditorManager.EngineManager.EntityClassManager.CreateCollection(this,_entityClass); } if (SerializationHelper.HasElement(info, "UIKey")) m_UIKey = info.GetString("UIKey"); }
void MigratePhysXEntityProperties(DynamicPropertyCollection entityProps, ShapeComponent havok) { { // Havok: "Dynamic/Keyframed/Fixed/Sphere Inertia/Box Inertia/Thin Box Inertia/Character" // PhysX: "Dynamic/Static/Kinematic" string sValue = (string)entityProps.GetPropertyValue("m_ePhysicsType", false); // since it is an enum, we get it as a string if (sValue == "Static") sValue = "Fixed"; else if (sValue == "Kinematic") sValue = "Keyframed"; havok.SetPropertyValue("Havok_MotionType", sValue, false); } { // Havok: "Box/Sphere/Convex Hull/File/Capsule/Cylinder/Mesh" // PhysX: "Box/Sphere/File/Hull/Mesh" string sValue = (string)entityProps.GetPropertyValue("m_ePhysicsGeom", false); // since it is an enum, we get it as a string if (sValue == "Hull" || sValue == "File") sValue = "Convex Hull"; // since PhysXFile + Havok_FileResourceName does not match, convert "File" to "Convex Hull" havok.SetPropertyValue("Shape_Type", sValue, false); } // mass of zero is not legal for dynamic rigid bodies in Havok. Furthermore, very old versions of the entity class // did not have a mass property, so additionally check whether the property is there object fValue = entityProps.GetPropertyValue("m_fMass", false); if ((fValue is float) && ((float)fValue) > 0.0f) havok.SetPropertyValue("Havok_Mass", fValue); havok.SetPropertyValue("Shape_Radius", entityProps.GetPropertyValue("m_fRadius", false)); havok.SetPropertyValue("Shape_BoxSize", entityProps.GetPropertyValue("m_bboxSize", false)); havok.SetPropertyValue("Shape_PivotOffset", entityProps.GetPropertyValue("m_bLocalOffset", false)); havok.SetPropertyValue("Debug_Render", entityProps.GetPropertyValue("DebugRendering", false)); }