示例#1
0
 private void SaveOpenedDocuments()
 {
     try
     {
         if (Services.ProjectOperations.CurrentSelectedSolution == null)
         {
             return;
         }
         List <Document>     documentList     = new List <Document>(Services.Workbench.Documents);
         List <FilePathData> filePathDataList = new List <FilePathData>();
         if (documentList != null)
         {
             foreach (Document document in documentList)
             {
                 filePathDataList.Add(new FilePathData((ResourceFile)document.Project));
             }
         }
         PropertyBag userProperties = Services.ProjectOperations.CurrentSelectedSolution.UserProperties;
         userProperties.SetValue <List <FilePathData> >("OpenedDocuments", filePathDataList);
         Project project = Services.Workbench.ActiveDocument != null ? Services.Workbench.ActiveDocument.Project : (Project)null;
         userProperties.SetValue <FilePathData>("ActiveDocuments", new FilePathData((ResourceFile)project));
         Services.ProjectOperations.CurrentSelectedSolution.SaveUserProperties();
     }
     catch (Exception ex)
     {
         LogConfig.Logger.Error((object)"Exception while saving infomation opened documents! ", ex);
     }
 }
示例#2
0
        private OrganizationMaintenanceJobData[] a(Guid A_0, int A_1, bool A_2 = false)
        {
            OrganizationMaintenanceJobData[] array;
            Guid scaleGroupId = LocatorService.Instance.GetScaleGroupId();
            Guid a0           = A_0;
            List <OrganizationMaintenanceJobData> organizationMaintenanceJobDatas = new List <OrganizationMaintenanceJobData>();
            PropertyBag           propertyBag           = null;
            PropertyBagCollection propertyBagCollection = null;

            using (ConfigurationDatabaseService configurationDatabaseService = new ConfigurationDatabaseService(scaleGroupId))
            {
                propertyBag = new PropertyBag();
                propertyBag.SetValue("OrganizationId", a0);
                if (!A_2)
                {
                    propertyBag.SetValue("OperationType", A_1);
                }
                propertyBagCollection = configurationDatabaseService.Retrieve((string)this.rscMgrTypeResources.GetObject("tblScaleGrp"), null, new PropertyBag[] { propertyBag });
                if (propertyBagCollection != null)
                {
                    SortedDictionary <object, PropertyBag> .Enumerator enumerator = propertyBagCollection.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        OrganizationMaintenanceJobData organizationMaintenanceJobDatum = new OrganizationMaintenanceJobData(enumerator.Current.Value);
                        if (!organizationMaintenanceJobDatum.Enabled)
                        {
                            continue;
                        }
                        organizationMaintenanceJobDatas.Add(organizationMaintenanceJobDatum);
                    }
                }
                array = organizationMaintenanceJobDatas.ToArray();
            }
            return(array);
        }
示例#3
0
        private IPropertyBag GetSceneRendererSettings(bool drawBackground, bool drawHighlight, bool drawSketch)
        {
            var key = Tuples.SameTypeTuple(drawBackground, drawHighlight, drawSketch);

            return(sceneRendererSettingsCache.GetOrAdd(key, x =>
            {
                var settings = new PropertyBag();
                settings.SetValue(SceneRenderer.IsStandardProp, true);
                settings.SetValue(SceneRenderer.DrawBackgroundProp, x.Item0);
                settings.SetValue(SceneRenderer.DrawHighlightProp, x.Item1);
                settings.SetValue(SceneRenderer.DrawSketchProp, x.Item2);
                return settings;
            }));
        }
示例#4
0
        public static void Wiggle(EntityManager em, ScriptContainer scriptContainer, int entityLiveId, GameTime gameTime)
        {
            PropertyBag propertyBag = scriptContainer.PropertyBag;
            Placement   placement   = (Placement)em.GetComponent(em.GetEntityByLiveId(entityLiveId), ComponentTypeIds.Placement);

            float ellapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;

            float period    = propertyBag.GetSingleValue(WigglePeriodId);
            float position  = propertyBag.GetSingleValue(PulsatePositionId, float.MaxValue);
            bool  needReset = false;

            if (position == float.MaxValue)
            {
                needReset = true;
                position  = 0;
            }
            position += ellapsed;
            if (position > period)
            {
                position -= period;
                needReset = true;
            }
            scriptContainer.PropertyBag.SetValue(PulsatePositionId, position);

            if (needReset)
            {
                float extent = propertyBag.GetSingleValue(WiggleExtentId);

                // Choose a new destination
                float xNewTarget = (float)(random.NextDouble() * 2f - 1f) * extent;
                float yNewTarget = (float)(random.NextDouble() * 2f - 1f) * extent;
                propertyBag.SetValue(WiggleXTargetId, xNewTarget);
                propertyBag.SetValue(WiggleYTargetId, yNewTarget);
                propertyBag.SetValue(WiggleXStartId, placement.AdditionalVisualPosition.X);
                propertyBag.SetValue(WiggleYStartId, placement.AdditionalVisualPosition.Y);
            }

            float xTarget = propertyBag.GetSingleValue(WiggleXTargetId);
            float yTarget = propertyBag.GetSingleValue(WiggleYTargetId);
            float xStart  = propertyBag.GetSingleValue(WiggleXStartId);
            float yStart  = propertyBag.GetSingleValue(WiggleYStartId);

            float progression = position / period;
            float x           = MathHelper.Lerp(xStart, xTarget, progression);
            float y           = MathHelper.Lerp(yStart, yTarget, progression);

            placement.AdditionalVisualPosition = new Vector3(x, y, 0);
        }
		public void SerializationDoubleRoundtrip ()
		{
			var bag = new PropertyBag ();
			var t = new SerializableObject {
				SomeValue = "test1"
			};
			bag.SetValue ("foo", t);

			var w = new StringWriter ();
			var ser = new XmlDataSerializer (new DataContext ());
			ser.Serialize (w, bag);
			var data = w.ToString ();

			SerializableObject.CreationCount = 0;

			bag = ser.Deserialize<PropertyBag> (new StringReader (data));

			// SerializableObject is not instantiated if not queried
			Assert.AreEqual (0, SerializableObject.CreationCount);

			w = new StringWriter ();
			ser.Serialize (w, bag);
			data = w.ToString ();

			bag = ser.Deserialize<PropertyBag> (new StringReader (data));

			// SerializableObject is not instantiated if not queried
			Assert.AreEqual (0, SerializableObject.CreationCount);

			t = bag.GetValue<SerializableObject> ("foo");
			Assert.NotNull (t);
			Assert.AreEqual ("test1", t.SomeValue);
		}
示例#6
0
        public void SerializationDoubleRoundtrip()
        {
            var bag = new PropertyBag();
            var t   = new SerializableObject {
                SomeValue = "test1"
            };

            bag.SetValue("foo", t);

            var w   = new StringWriter();
            var ser = new XmlDataSerializer(new DataContext());

            ser.Serialize(w, bag);
            var data = w.ToString();

            SerializableObject.CreationCount = 0;

            bag = ser.Deserialize <PropertyBag> (new StringReader(data));

            // SerializableObject is not instantiated if not queried
            Assert.AreEqual(0, SerializableObject.CreationCount);

            w = new StringWriter();
            ser.Serialize(w, bag);
            data = w.ToString();

            bag = ser.Deserialize <PropertyBag> (new StringReader(data));

            // SerializableObject is not instantiated if not queried
            Assert.AreEqual(0, SerializableObject.CreationCount);

            t = bag.GetValue <SerializableObject> ("foo");
            Assert.NotNull(t);
            Assert.AreEqual("test1", t.SomeValue);
        }
示例#7
0
 protected bool SetValue <TProperty>(
     TProperty value,
     [CallerMemberName] string propertyName = "")
 {
     return(_propertyBag.SetValue(
                value,
                propertyName));
 }
示例#8
0
        public void ShouldProvideFluentInterfaceForBuildingMetadata()
        {
            PropertyBag extraMetadata = new PropertyBag();
            extraMetadata.SetValue("Author", "Lewis Carroll");
            extraMetadata.SetValue("Title", "The Jabberwocky");

            DataRow row = new DataRow("abc")
                .WithMetadata("Description", "Frumious")
                .WithMetadata("Name", "Bandersnatch")
                .WithMetadata(extraMetadata);
            Assert.AreEqual("abc", row.GetValue(new DataBinding(0, null)));

            PropertyBag map = DataItemUtils.GetMetadata(row);
            Assert.Count(4, map);
            Assert.AreEqual("Frumious", map.GetValue("Description"));
            Assert.AreEqual("Bandersnatch", map.GetValue("Name"));
            Assert.AreEqual("Lewis Carroll", map.GetValue("Author"));
            Assert.AreEqual("The Jabberwocky", map.GetValue("Title"));
        }
示例#9
0
        public void ShouldProvideFluentInterfaceForBuildingMetadata()
        {
            PropertyBag extraMetadata = new PropertyBag();

            extraMetadata.SetValue("Author", "Lewis Carroll");
            extraMetadata.SetValue("Title", "The Jabberwocky");

            DataRow row = new DataRow("abc")
                          .WithMetadata("Description", "Frumious")
                          .WithMetadata("Name", "Bandersnatch")
                          .WithMetadata(extraMetadata);

            Assert.AreEqual("abc", row.GetValue(new DataBinding(0, null)));

            PropertyBag map = DataItemUtils.GetMetadata(row);

            Assert.Count(4, map);
            Assert.AreEqual("Frumious", map.GetValue("Description"));
            Assert.AreEqual("Bandersnatch", map.GetValue("Name"));
            Assert.AreEqual("Lewis Carroll", map.GetValue("Author"));
            Assert.AreEqual("The Jabberwocky", map.GetValue("Title"));
        }
示例#10
0
        public static void SetDefaultSerializer(Solution sln)
        {
            PropertyBag userProperties = sln.UserProperties;
            string      baseDirectory  = (string)sln.BaseDirectory;

            if (!string.IsNullOrEmpty(userProperties.GetValue <string>("DefaultSerializer", string.Empty)))
            {
                return;
            }
            string defaultSerializerId = VersionHelper.GetDefaultSerializerID(sln);

            userProperties.SetValue <string>("DefaultSerializer", defaultSerializerId);
            sln.SaveUserProperties();
        }
示例#11
0
        public void GetAndSetValue()
        {
            PropertyBag bag = new PropertyBag();

            Assert.IsNull(bag.GetValue("key"));

            bag.SetValue("key", "value");
            Assert.AreEqual("value", bag.GetValue("key"));

            bag.SetValue("key", "different value");
            Assert.AreEqual("different value", bag.GetValue("key"));

            bag.SetValue("key", null);
            Assert.IsNull(bag.GetValue("key"));

            bag.Add("key", "value1");
            bag.Add("key", "value2");
            Assert.AreEqual("value1", bag.GetValue("key"));
            Assert.AreElementsEqual(new[] { "value1", "value2" }, bag["key"]);

            bag.SetValue("key", "value");
            Assert.AreElementsEqual(new[] { "value" }, bag["key"]);
        }
示例#12
0
        void CollectItemProperties(PropertyBag props, SolutionItem item, string path)
        {
            if (!item.UserProperties.IsEmpty && item.ParentFolder != null)
            {
                props.SetValue(path, item.UserProperties);
            }

            SolutionFolder sf = item as SolutionFolder;

            if (sf != null)
            {
                foreach (SolutionItem ci in sf.Items)
                {
                    CollectItemProperties(props, ci, path + "." + ci.Name);
                }
            }
        }
示例#13
0
 private static string GetDefaultSerializerID(Solution sln)
 {
     try
     {
         PropertyBag userProperties = sln.UserProperties;
         string      empty          = string.Empty;
         if (!userProperties.GetValue <bool>("publishHasCocos2dxCode", true))
         {
             return("Serializer_FlatBuffers");
         }
         if (userProperties.HasValue("publishCocos2dxMainVersion"))
         {
             if (userProperties.GetValue <int>("publishCocos2dxMainVersion") == 2)
             {
                 return("Serializer_Json");
             }
         }
         else
         {
             string versionFileV2 = VersionHelper.TryGetVersionFileV2(sln);
             if (!string.IsNullOrEmpty(versionFileV2))
             {
                 userProperties.SetValue <string>("publishCocos2dxVersionText", versionFileV2);
                 userProperties.SetValue <int>("publishCocos2dxMainVersion", 2);
                 return("Serializer_Json");
             }
         }
         if (userProperties.HasValue("publishCocos2dxCodeLanguage"))
         {
             if (userProperties.GetValue <EnumProjectLanguage>("publishCocos2dxCodeLanguage") == EnumProjectLanguage.js)
             {
                 return("Serializer_Json");
             }
         }
         else
         {
             string versionFileV3Js = VersionHelper.TryGetVersionFileV3_js(sln);
             if (!string.IsNullOrEmpty(versionFileV3Js))
             {
                 userProperties.SetValue <string>("publishCocos2dxVersionText", versionFileV3Js);
                 userProperties.SetValue <int>("publishCocos2dxMainVersion", 3);
                 userProperties.SetValue <EnumProjectLanguage>("publishCocos2dxCodeLanguage", EnumProjectLanguage.js);
                 return("Serializer_Json");
             }
         }
         string versionText1 = userProperties.GetValue <string>("publishCocos2dxVersionText", string.Empty);
         if (!string.IsNullOrEmpty(versionText1))
         {
             return(VersionHelper.IsSupportBinary(versionText1) ? "Serializer_FlatBuffers" : "Serializer_Json");
         }
         string versionText2 = VersionHelper.TryGetVersionFileV3_cpp(sln);
         if (string.IsNullOrEmpty(versionText2))
         {
             versionText2 = VersionHelper.TryGetVersionFileV3_lua(sln);
         }
         if (!string.IsNullOrEmpty(versionText2))
         {
             return(VersionHelper.IsSupportBinary(versionText2) ? "Serializer_FlatBuffers" : "Serializer_Json");
         }
         string versionFileDefaultLua = VersionHelper.TryGetVersionFileDefault_lua(sln);
         if (string.IsNullOrEmpty(versionFileDefaultLua))
         {
             return("Serializer_FlatBuffers");
         }
         userProperties.SetValue <string>("publishCocos2dxVersionText", versionFileDefaultLua);
         return("Serializer_FlatBuffers");
     }
     catch (Exception ex)
     {
         LogConfig.Logger.Error((object)("获取默认发布器时出错:\r\n" + ex.ToString()));
         return("Serializer_FlatBuffers");
     }
 }
示例#14
0
        public void GetAndSetValue()
        {
            PropertyBag bag = new PropertyBag();

            Assert.IsNull(bag.GetValue("key"));

            bag.SetValue("key", "value");
            Assert.AreEqual("value", bag.GetValue("key"));

            bag.SetValue("key", "different value");
            Assert.AreEqual("different value", bag.GetValue("key"));

            bag.SetValue("key", null);
            Assert.IsNull(bag.GetValue("key"));

            bag.Add("key", "value1");
            bag.Add("key", "value2");
            Assert.AreEqual("value1", bag.GetValue("key"));
            Assert.AreElementsEqual(new[] { "value1", "value2" }, bag["key"]);

            bag.SetValue("key", "value");
            Assert.AreElementsEqual(new[] { "value" }, bag["key"]);
        }