public void ChainedSourceTest()
        {
            DynamicProperties.Instance = null;
            var properties = DynamicProperties.Init(1);

            var source = new StaticConfigurationSource();

            ((DynamicProperties)properties).RegisterSource(source);

            var chained = properties.Factory.AsChainedProperty("test10", 30, "test20");

            Assert.Equal(30, properties.Factory.AsChainedProperty("test10", 30, "test20").Value);

            source.Set("test20", 20);
            Thread.Sleep(properties.PollingIntervalInSeconds * 1200);
            Assert.Equal(20, chained.Value);

            source.Set("test10", 10);
            Thread.Sleep(properties.PollingIntervalInSeconds * 1100);
            Assert.Equal(10, chained.Value);

            source.Set("test10", 11);
            Thread.Sleep(properties.PollingIntervalInSeconds * 1100);
            Assert.Equal(11, chained.Value);
        }
Example #2
0
        public HttpResponseMessage SaveInstance(DynamicProperties props)
        {
            try
            {
                if (props == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.InternalServerError,
                                                  "Empty DynamicProperties passed to Put method!"));
                }

                var ds = MainService.Container.Resolve <DataService>();
                if (ds == null)
                {
                    return(null);
                }
                if (ds.SavePropertiesInstance(props))
                {
                    return(Request.CreateResponse(HttpStatusCode.OK));
                }
                return(Request.CreateResponse(HttpStatusCode.ExpectationFailed, "Failed to update"));
            }
            catch (Exception e)
            {
                log.Info(e.ToString());
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, e.ToString()));
            }
        }
Example #3
0
    public override void ParseProperties(DynamicProperties properties)
    {
        if (properties.Values.ContainsKey("PrefabName"))
        {
            this.strPOIname = properties.Values["PrefabName"];
        }
        if (properties.Values.ContainsKey("PrefabNames"))
        {
            List <String> TempList = new List <string>();
            string        strTemp  = properties.Values["PrefabNames"].ToString();

            string[] array = strTemp.Split(new char[] { ',' });
            for (int i = 0; i < array.Length; i++)
            {
                if (TempList.Contains(array[i].ToString()))
                {
                    continue;
                }
                TempList.Add(array[i].ToString());
            }
            var random = new System.Random();
            int index  = random.Next(TempList.Count);

            if (TempList.Count == 0)
            {
                Debug.Log(" ObjectiveGoToPOISDX PrefabNames Contains no prefabs.");
            }
            else
            {
                this.strPOIname = TempList[index];
            }
        }
        base.ParseProperties(properties);
    }
Example #4
0
        private static List <BCMLootBuffAction> GetExplosionBuffs(DynamicProperties _properties)
        {
            var ExplosionBuffs = new List <BCMLootBuffAction>();

            var names = _properties.Values["Explosion.Buff"].Split(',');

            string[] probs = null;
            if (_properties.Values.ContainsKey("Explosion.Buff_chance"))
            {
                probs = _properties.Values["Explosion.Buff_chance"].Split(',');
            }
            for (var i = 0; i < names.Length; i++)
            {
                var    name = names[i].Trim();
                double prob = 1;
                if (probs != null && i < probs.Length)
                {
                    prob = Utils.ParseFloat(probs[i].Trim());
                }

                ExplosionBuffs.Add(new BCMLootBuffAction {
                    BuffId = name, Chance = prob
                });
            }

            return(ExplosionBuffs);
        }
        public static void Main()
        {
            DynamicProperties.Init(pollingIntervalInSeconds: 10)
            .WithSources()
            .AddSource(new HttpConfigurationSource("http://localhost:5000"))
            .Initialize();

            var prop1 = DynamicProperties.Instance.GetOrCreateProperty <bool>("sample.prop1");
            var prop2 = DynamicProperties.Instance.GetOrCreateProperty <int>("sample.prop2");
            var prop3 = DynamicProperties.Instance.GetOrCreateProperty <string>("sample.prop3");
            var prop4 = DynamicProperties.Factory.AsProperty(50L);

            // Add "sample.prop5": 20 in the properties.json file on the server side
            var prop5 = DynamicProperties.Factory.AsChainedProperty("sample.prop5", 0L, "sample.prop2");

            do
            {
                Console.WriteLine($"prop1={prop1}");
                Console.WriteLine($"prop2={prop2}");
                Console.WriteLine($"prop3={prop3}");
                Console.WriteLine($"prop4={prop4}");
                Console.WriteLine($"prop5={prop5}");
                Console.ReadKey();
            }while (true);
        }
Example #6
0
        public static List <BCMDamageMultiplier> GetDamageMultiplier(DynamicProperties _properties)
        {
            var DamageMultipliers = new List <BCMDamageMultiplier>();

            const string _prefix = "Explosion.DamageBonus.";

            using (var enumerator = _properties.Values.Keys.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    var current = enumerator.Current;
                    if (current == null)
                    {
                        continue;
                    }

                    if (current.StartsWith(_prefix))
                    {
                        DamageMultipliers.Add(
                            new BCMDamageMultiplier
                        {
                            Type  = current.Substring(_prefix.Length),
                            Value = Utils.ParseFloat(_properties.Values[current])
                        });
                    }
                }
            }

            return(DamageMultipliers);
        }
Example #7
0
        public BCMExplosionData(DynamicProperties _properties)
        {
            if (_properties.Values.ContainsKey("Explosion.ParticleIndex"))
            {
                ParticleIndex = (int)Utils.ParseFloat(_properties.Values["Explosion.ParticleIndex"]);
            }
            else
            {
                ParticleIndex = 0;
            }

            if (_properties.Values.ContainsKey("Explosion.RadiusBlocks"))
            {
                BlockRadius = (int)Utils.ParseFloat(_properties.Values["Explosion.RadiusBlocks"]);
            }

            if (_properties.Values.ContainsKey("Explosion.BlockDamage"))
            {
                BlockDamage = Utils.ParseFloat(_properties.Values["Explosion.BlockDamage"]);
            }
            else
            {
                BlockDamage = BlockRadius * BlockRadius;
            }

            if (_properties.Values.ContainsKey("Explosion.RadiusEntities"))
            {
                EntityRadius = (int)Utils.ParseFloat(_properties.Values["Explosion.RadiusEntities"]);
            }

            if (_properties.Values.ContainsKey("Explosion.EntityDamage"))
            {
                EntityDamage = Utils.ParseFloat(_properties.Values["Explosion.EntityDamage"]);
            }
            else
            {
                EntityDamage = 20f * EntityRadius;
            }

            if (_properties.Values.ContainsKey("Explosion.RadiusBuffs"))
            {
                BuffsRadius = (int)Utils.ParseFloat(_properties.Values["Explosion.RadiusBuffs"]);
            }
            else
            {
                BuffsRadius = EntityRadius;
            }

            //if (_properties.Values.ContainsKey("Explosion.BlastPower"))
            //{
            //  BlastPower = (int)Utils.ParseFloat(_properties.Values["Explosion.BlastPower"]);
            //}

            if (_properties.Values.ContainsKey("Explosion.Buff"))
            {
                BuffActions = GetExplosionBuffs(_properties);
            }

            DamageMultipliers = GetDamageMultiplier(_properties);
        }
 // Required ctor for ICapabilityViewer
 public PresentationCapability(DynamicProperties dynaProps)
     : base(dynaProps)
 {
     // When initialized as a player, this capability disables the sending of slides
     // so there is no need for a background senders
     capProps.BackgroundSender = false;
 }
Example #9
0
    public static bool CheckFeatureStatus(string strClass, string strFeature)
    {
        BlockValue ConfigurationFeatureBlock = Block.GetBlockValue("ConfigFeatureBlock");

        if (ConfigurationFeatureBlock.type == 0)
        {
            // AdvLogging.DisplayLog("Configuration", "Feature: " + strFeature + " No Configuration Block");
            return(false);
        }



        bool result = false;

        if (ConfigurationFeatureBlock.Block.Properties.Classes.ContainsKey(strClass))
        {
            DynamicProperties dynamicProperties3 = ConfigurationFeatureBlock.Block.Properties.Classes[strClass];
            foreach (System.Collections.Generic.KeyValuePair <string, object> keyValuePair in dynamicProperties3.Values.Dict.Dict)
            {
                if (string.Equals(keyValuePair.Key, strFeature, System.StringComparison.CurrentCultureIgnoreCase))
                {
                    result = StringParsers.ParseBool(dynamicProperties3.Values[keyValuePair.Key]);
                }
            }
        }

        //  UnityEngine.Debug.Log(" Configuration:  " + strClass + " : " + strFeature + " : Result: " + result);
        //ConsoleCmdAIDirectorDebug.("Configuration", "Feature: " + strFeature + " Result: " + result);
        return(result);
    }
Example #10
0
        // Used on reading from source. Get full list of rules for this control.
        public Dictionary <string, string> GetDefaultRules()
        {
            // Add themes first.
            var defaults        = new Dictionary <string, string>();
            var variantDefaults = new Dictionary <string, string>();

            if (_template != null)
            {
                // Default values from the variants take precedence over the base template
                var hasVariantDefaults = _variantName != null && _template.VariantDefaultValues.TryGetValue(_variantName, out variantDefaults);
                if (hasVariantDefaults)
                {
                    defaults.AddRange(variantDefaults);
                }

                defaults.AddRange(_template.InputDefaults.Where(kvp => !IsLocalizationKey(kvp.Value) && !(hasVariantDefaults && variantDefaults.ContainsKey(kvp.Key))));
            }

            defaults.AddRange(_theme.GetStyle(_styleName).Where(kvp => !IsLocalizationKey(kvp.Value)));

            if (_inResponsiveContext)
            {
                defaults.AddRange(DynamicProperties.GetDefaultValues(_templateName, this));
            }

            return(defaults);
        }
    static void ShowWindow()
    {
        DynamicProperties window = EditorWindow.GetWindow <DynamicProperties>();

        window.titleContent = new GUIContent("Dynamic Properties Demo");
        window.minSize      = new Vector2(200f, 600f);
    }
Example #12
0
        /// <summary>
        /// Converts a property to the given type
        /// </summary>
        /// <param name="name">Name of the property to convert</param>
        /// <param name="type">Type to convert to</param>
        /// <param name="defaultValue">Default value to use if conversion fails</param>
        public MigrationContainer ConvertValueOrDefault(string name, Type type, object defaultValue = null)
        {
            var property = m_PropertyBag.FindProperty(name);

            if (null == property)
            {
                throw new Exception($"{nameof(MigrationContainer)}.{nameof(ConvertValueOrDefault)} no property found with the name `{name}`");
            }

            // @TODO Type check

            // Grab the existing value
            var value = (property as IValueProperty)?.GetObjectValue(this);

            // Setup the backing storage for the value
            if (null != value)
            {
                // Try to convert the object to the new type. If this fails, fallback to the defaultValue
                m_Data[name] = TypeConversion.Convert(value, type) ?? defaultValue;
            }
            else
            {
                // @NOTE We do NOT assign the default value in this path since the value might have been explicitly set to null
                m_Data[name] = null;
            }

            // Replace the property with a newly generated one of the correct type
            m_PropertyBag.ReplaceProperty(name, DynamicProperties.CreateValueProperty(name, type));

            return(this);
        }
Example #13
0
 public IEnumerable <DynamicProperties> GetAllProperties()
 {
     try
     {
         List <DynamicProperties> results = new List <DynamicProperties>();
         var result = props.GetAll();
         if (!result.Any())
         {
             return(results);
         }
         result.ForEach(x =>
         {
             DynamicProperties dynProps = new DynamicProperties();
             if (toPropsDTO(x, ref dynProps))
             {
                 results.Add(dynProps);
             }
         });
         return(results);
     }
     catch (Exception e)
     {
         log.Error("Error: GetAllProperties: " + e);
     }
     return(null);
 }
Example #14
0
        public RenderingItem([CanBeNull] IRenderingContainer renderingContainer, [NotNull] DatabaseUri databaseUri, [NotNull] XElement element, bool isDuplicate) : this(renderingContainer, databaseUri, element)
        {
            Assert.ArgumentNotNull(databaseUri, nameof(databaseUri));
            Assert.ArgumentNotNull(element, nameof(element));

            hasParameters = isDuplicate;
            if (!isDuplicate)
            {
                return;
            }

            UniqueId = Guid.NewGuid().ToString("B").ToUpperInvariant();

            var idProperty = DynamicProperties.FirstOrDefault(p => string.Compare(p.Name, @"id", StringComparison.InvariantCultureIgnoreCase) == 0);

            if (idProperty != null)
            {
                var n = idProperty.Value as string;
                if (!string.IsNullOrEmpty(n))
                {
                    n = n.TrimEnd('0', '1', '2', '3', '4', '5', '6', '7', '8', '9');
                }
                else
                {
                    n = Name;
                }

                disableRenaming  = true;
                idProperty.Value = GetNewControlId(n.GetSafeCodeIdentifier());
                disableRenaming  = false;
            }
        }
        public CorporationHangarRentInfo GetCorporationHangarRentInfo()
        {
            var saveNeeded = false;

            if (!DynamicProperties.Contains(k.hangarPrice))
            {
                DynamicProperties.Update(k.hangarPrice, _corporationConfiguration.HangarPrice);
                saveNeeded = true;
            }

            if (!DynamicProperties.Contains(k.rentPeriod))
            {
                DynamicProperties.Update(k.rentPeriod, _corporationConfiguration.RentPeriod);
                saveNeeded = true;
            }

            if (saveNeeded)
            {
                this.Save();
            }

            return(new CorporationHangarRentInfo
            {
                price = DynamicProperties.GetOrAdd <int>(k.hangarPrice),
                period = TimeSpan.FromDays(DynamicProperties.GetOrAdd <int>(k.rentPeriod))
            });
        }
Example #16
0
        public virtual object Clone()
        {
            var result = MemberwiseClone() as FrontMatterHeaders;

            result.DynamicProperties = DynamicProperties?.Select(x => x.Clone()).OfType <DynamicObjectProperty>().ToList();
            return(result);
        }
        public void MultiSourceTest()
        {
            DynamicProperties.Instance = null;
            var properties = (DynamicProperties)DynamicProperties.Init(1);

            var source1 = new StaticConfigurationSource();

            properties.RegisterSource(source1);

            var source2 = new StaticConfigurationSource();

            properties.RegisterSource(source2);

            var prop = properties.GetOrCreateProperty <int>("test30");

            Assert.Equal(0, prop.Value);

            source1.Set("test30", 10);
            Thread.Sleep(properties.PollingIntervalInSeconds * 1100);
            Assert.Equal(10, prop.Value);

            source2.Set("test30", 20);
            Thread.Sleep(properties.PollingIntervalInSeconds * 1100);
            Assert.Equal(20, prop.Value);
        }
        public void ApplyAfterRead(BlockNode control, bool inResponsiveContext = false)
        {
            var controlTemplateName        = control.Name?.Kind?.TypeName ?? string.Empty;
            var controlTemplateVariantName = control.Name?.Kind?.OptionalVariant ?? string.Empty;

            var childResponsiveContext = DynamicProperties.AddsChildDynamicProperties(controlTemplateName, controlTemplateVariantName);

            foreach (var child in control.Children)
            {
                ApplyAfterRead(child, childResponsiveContext);
            }

            // Apply default values first, before re-arranging controls
            _defaultValTransform.AfterRead(control, inResponsiveContext);

            foreach (var transform in _templateTransforms)
            {
                if (transform.TargetTemplates.Contains(controlTemplateName))
                {
                    transform.AfterRead(control);
                }
            }

            _groupControlTransform.AfterRead(control);
        }
    // Over-ride for CopyProperties to allow it to read in StartingQuests.
    public override void CopyPropertiesFromEntityClass()
    {
        base.CopyPropertiesFromEntityClass();
        EntityClass entityClass = EntityClass.list[this.entityClass];

        flEyeHeight = EntityUtilities.GetFloatValue(entityId, "EyeHeight");

        // Read in a list of names then pick one at random.
        if (entityClass.Properties.Values.ContainsKey("Names"))
        {
            string   text  = entityClass.Properties.Values["Names"];
            string[] Names = text.Split(',');

            int index = UnityEngine.Random.Range(0, Names.Length);
            strMyName = Names[index];
        }

        if (entityClass.Properties.Values.ContainsKey("SleeperInstantAwake"))
        {
            isAlwaysAwake = true;
        }

        if (entityClass.Properties.Values.ContainsKey("Titles"))
        {
            string   text  = entityClass.Properties.Values["Titles"];
            string[] Names = text.Split(',');
            int      index = UnityEngine.Random.Range(0, Names.Length);
            strTitle = Names[index];
        }


        if (entityClass.Properties.Classes.ContainsKey("Boundary"))
        {
            DisplayLog(" Found Bandary Settings");
            String            strBoundaryBox     = "0,0,0";
            String            strCenter          = "0,0,0";
            DynamicProperties dynamicProperties3 = entityClass.Properties.Classes["Boundary"];
            foreach (KeyValuePair <string, object> keyValuePair in dynamicProperties3.Values.Dict.Dict)
            {
                DisplayLog("Key: " + keyValuePair.Key);
                if (keyValuePair.Key == "BoundaryBox")
                {
                    DisplayLog(" Found a Boundary Box");
                    strBoundaryBox = dynamicProperties3.Values[keyValuePair.Key];
                    continue;
                }

                if (keyValuePair.Key == "Center")
                {
                    DisplayLog(" Found a Center");
                    strCenter = dynamicProperties3.Values[keyValuePair.Key];
                    continue;
                }
            }

            Vector3 Box    = StringParsers.ParseVector3(strBoundaryBox, 0, -1);
            Vector3 Center = StringParsers.ParseVector3(strCenter, 0, -1);
            ConfigureBounaryBox(Box, Center);
        }
    }
Example #20
0
        // Used on writing to source to omit default rules.
        public bool TryGetDefaultRule(string propertyName, out string defaultScript)
        {
            // Themes (styles) are higher precedence  then Template XML.
            var template = _template;

            if (_theme.TryLookup(_styleName, propertyName, out defaultScript))
            {
                if (IsLocalizationKey(defaultScript))
                {
                    return(false);
                }
                return(true);
            }

            if (template != null && template.InputDefaults.TryGetValue(propertyName, out defaultScript))
            {
                if (IsLocalizationKey(defaultScript))
                {
                    return(false);
                }

                // Found in template.
                return(true);
            }

            if (_inResponsiveContext && DynamicProperties.TryGetDefaultValue(propertyName, _templateName, this, out defaultScript))
            {
                return(true);
            }

            defaultScript = null;
            return(false);
        }
Example #21
0
    public static string GetPropertyValue(string strClass, string strFeature)
    {
        BlockValue ConfigurationFeatureBlock = Block.GetBlockValue("ConfigFeatureBlock");

        if (ConfigurationFeatureBlock.type == 0)
        {
            return(string.Empty);
        }


        string result = string.Empty;

        if (ConfigurationFeatureBlock.Block.Properties.Classes.ContainsKey(strClass))
        {
            DynamicProperties dynamicProperties3 = ConfigurationFeatureBlock.Block.Properties.Classes[strClass];
            foreach (KeyValuePair <string, object> keyValuePair in dynamicProperties3.Values.Dict.Dict)
            {
                if (keyValuePair.Key == strFeature)
                {
                    return(keyValuePair.Value.ToString());
                }
            }
        }

        return(result);
    }
Example #22
0
        public ActionResult SaveInstance(DynamicProperties props)
        {
            try
            {
                if (props == null)
                {
                    return(Problem("Empty DynamicProperties passed to Put method!",
                                   "Error", StatusCodes.Status500InternalServerError));
                }

                var ds = MainService.Container.Resolve <DataService>();
                if (ds == null)
                {
                    return(null);
                }
                if (ds.SavePropertiesInstance(props))
                {
                    return(Ok());
                }
                return(Problem("Failed to update", "Error", StatusCodes.Status417ExpectationFailed));
            }
            catch (Exception e)
            {
                log.Info(e.ToString());
                return(Problem(e.ToString(), "Error", StatusCodes.Status500InternalServerError));
            }
        }
Example #23
0
    public static bool CheckFeatureStatus(string strClass, string strFeature)
    {
        BlockValue ConfigurationFeatureBlock = Block.GetBlockValue("ConfigFeatureBlock");

        if (ConfigurationFeatureBlock.type == 0)
        {
            return(false);
        }

        bool result = false;

        if (ConfigurationFeatureBlock.Block.Properties.Classes.ContainsKey(strClass))
        {
            DynamicProperties dynamicProperties3 = ConfigurationFeatureBlock.Block.Properties.Classes[strClass];
            foreach (System.Collections.Generic.KeyValuePair <string, object> keyValuePair in dynamicProperties3.Values.Dict.Dict)
            {
                if (string.Equals(keyValuePair.Key, strFeature, System.StringComparison.CurrentCultureIgnoreCase))
                {
                    result = StringParsers.ParseBool(dynamicProperties3.Values[keyValuePair.Key]);
                }
            }
        }

        return(result);
    }
        protected PBSEffectNode()
        {
            _standingController = new PBSStandingController <PBSEffectNode>(this)
            {
                AlwaysEnabled = true
            };
            _coreUseHandler = new CoreUseHandler <PBSEffectNode>(this, new EnergyStateFactory(this));

            _currentEffect = DynamicProperties.GetProperty <int>(k.currentEffect);
            _currentEffect.PropertyChanging += (property, value) =>
            {
                var effectType = (EffectType)value;

                if (effectType == EffectType.undefined)
                {
                    effectType = AvailableEffects.FirstOrDefault();
                }

                if (!AvailableEffects.Contains(effectType))
                {
                    Logger.Error("PBSEffectNode: invalid effect type! type:" + effectType);
                }

                RemoveCurrentEffect();
                return((int)effectType);
            };

            _currentEffect.PropertyChanged += property =>
            {
                OnEffectChanged();
            };
        }
        void clear()
        {
            Filename        = "";
            ReplaceFilename = "";
            Location        = "";

            Rating      = 0;
            Title       = "";
            Description = "";
            Author      = "";
            Copyright   = "";
            Creation    = null;
            IsImported  = false;
            Geotag      = new GeoTagCoordinatePair();

            lock (itemsLock)
            {
                DynamicProperties.Clear();
            }

            SelectedMetaDataPreset = noPresetMetaData;

            lock (tagsLock)
            {
                Tags.Clear();
            }
            lock (addTagsLock)
            {
                AddTags.Clear();
            }
            lock (removeTagsLock)
            {
                RemoveTags.Clear();
            }
        }
Example #26
0
 public string GetProductPreviewInfo()
 {
     return(string.Join(" | ",
                        DynamicProperties.Where(obj => !obj.IsBool)
                        .Take(6)
                        .Select(i => string.Format("{0}: {1}", i.Key, i.Value))));
 }
        public static bool Prefix(ref string value, BindingItem binding, ItemClass ___itemClass)
        {
            // Check if this feature is enabled.
            if (!Configuration.CheckFeatureStatus(AdvFeatureClass, Feature))
            {
                return(true);
            }

            if (___itemClass == null)
            {
                return(true);
            }

            string text = binding.FieldName;

            if (text == "itemRepairDescription")
            {
                AdvLogging.DisplayLog(AdvFeatureClass, "Reading Custom Repair description");

                string descriptionKey2 = ___itemClass.DescriptionKey;
                if (Localization.Exists(descriptionKey2, ""))
                {
                    value = Localization.Get(descriptionKey2, "");
                }

                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.Append(Localization.Get("lblRepairItems", ""));

                List <ItemStack> stack = new List <ItemStack>();
                // Check if ScrapItems is specified
                if (___itemClass.Properties.Classes.ContainsKey("RepairItems"))
                {
                    DynamicProperties dynamicProperties3 = ___itemClass.Properties.Classes["RepairItems"];
                    stack = ItemsUtilities.ParseProperties(dynamicProperties3);
                }
                else if (___itemClass.Properties.Contains("RepairItems")) // to support <property name="RepairItems" value="resourceWood,10,resourceForgedIron,10" />
                {
                    string strData = ___itemClass.Properties.Values["RepairItems"].ToString();
                    stack = ItemsUtilities.ParseProperties(strData);
                }
                else if (___itemClass.RepairTools == null || ___itemClass.RepairTools.Length <= 0)
                {
                    Recipe recipe = ItemsUtilities.GetReducedRecipes(___itemClass.GetItemName(), 2);
                    stack = recipe.ingredients;
                }
                if (stack.Count > 0)
                {
                    stringBuilder.Append(ItemsUtilities.GetStackSummary(stack));
                    value = stringBuilder.ToString();
                }
                else
                {
                    stringBuilder.Append(" You cannot repair this.");
                    value = stringBuilder.ToString();
                }
                return(false);
            }
            return(true);
        }
Example #28
0
 public override void ParseProperties(DynamicProperties properties)
 {
     if (properties.Values.ContainsKey("PrefabName"))
     {
         this.strPOIname = properties.Values["PrefabName"];
     }
     base.ParseProperties(properties);
 }
        public virtual async Task <DynamicPropertyEntity[]> GetObjectDynamicPropertiesAsync(string[] objectTypes)
        {
            var properties = await DynamicProperties.Include(x => x.DisplayNames)
                             .OrderBy(x => x.Name)
                             .Where(x => objectTypes.Contains(x.ObjectType)).ToArrayAsync();

            return(properties);
        }
        public static bool Prefix(ItemActionEntryRepair __instance)
        {
            // Check if this feature is enabled.
            if (!Configuration.CheckFeatureStatus(AdvFeatureClass, Feature))
            {
                return(true);
            }

            XUi               xui       = __instance.ItemController.xui;
            ItemValue         itemValue = ((XUiC_ItemStack)__instance.ItemController).ItemStack.itemValue;
            ItemClass         forId     = ItemClass.GetForId(itemValue.type);
            EntityPlayerLocal player    = xui.playerUI.entityPlayer;

            XUiC_CraftingWindowGroup childByType = xui.FindWindowGroupByName("crafting").GetChildByType <XUiC_CraftingWindowGroup>();

            List <ItemStack> repairItems = new List <ItemStack>();

            // If the item has a repairItems, use that, instead of the vanilla version.
            if (forId.Properties.Classes.ContainsKey("RepairItems"))
            {
                Recipe            recipe             = new Recipe();
                DynamicProperties dynamicProperties3 = forId.Properties.Classes["RepairItems"];
                recipe.ingredients = ItemsUtilities.ParseProperties(dynamicProperties3);

                // Get an adjusted Craftint time from the player.
                recipe.craftingTime = (int)EffectManager.GetValue(PassiveEffects.CraftingTime, null, recipe.craftingTime, xui.playerUI.entityPlayer, recipe, FastTags.Parse(recipe.GetName()), true, true, true, true, 1, true);
                ItemsUtilities.ConvertAndCraft(recipe, player, __instance.ItemController);
                return(false);
            }
            else if (forId.Properties.Contains("RepairItems")) // to support <property name="RepairItems" value="resourceWood,10,resourceForgedIron,10" />
            {
                Recipe recipe  = new Recipe();
                string strData = forId.Properties.Values["RepairItems"].ToString();
                recipe.ingredients = ItemsUtilities.ParseProperties(strData);

                // Get an adjusted Craftint time from the player.
                recipe.craftingTime = (int)EffectManager.GetValue(PassiveEffects.CraftingTime, null, recipe.craftingTime, xui.playerUI.entityPlayer, recipe, FastTags.Parse(recipe.GetName()), true, true, true, true, 1, true);
                ItemsUtilities.ConvertAndCraft(recipe, player, __instance.ItemController);
                return(false);
            }
            // If there's no RepairTools defined, then fall back to recipe reduction
            else if (forId.RepairTools == null || forId.RepairTools.Length <= 0)
            {
                // Determine, based on percentage left,
                int RecipeCountReduction = 2;
                if (itemValue.PercentUsesLeft < 0.2)
                {
                    RecipeCountReduction = 3;
                }

                // Use the helper method to reduce the recipe count, and control displaying on the UI for consistenncy.
                ItemsUtilities.ConvertAndCraft(forId.GetItemName(), RecipeCountReduction, player, __instance.ItemController);
                return(false);
            }

            // Fall back to possible RepairTools
            return(true);
        }
Example #31
0
        public DynamicPropertyEntity[] GetDynamicPropertiesForType(string objectType)
        {
            var retVal = DynamicProperties.Include(p => p.DisplayNames)
                         .Where(p => p.ObjectType == objectType)
                         .OrderBy(p => p.Name)
                         .ToArray();

            return(retVal);
        }
Example #32
0
        public static DynamicProperties DynaPropsFromRtpStream(RtpStream rtpStream)
        {
            DynamicProperties dynaProps = new DynamicProperties();

            dynaProps.ID = IDFromRtpStream(rtpStream);
            dynaProps.Name = rtpStream.Properties.Name;
            dynaProps.SharedFormID = SharedFormIDFromRtpStream(rtpStream);

            // Establish the channelness or ownership of this capability
            CapabilityType streamType = ChannelFromRtpStream(rtpStream);
            // by default, capabilities are owned (i.e. the "unknown" streams are considered owned)
            dynaProps.Channel = (streamType == CapabilityType.Channel);
            if (streamType == CapabilityType.Owned) // the stream is being sent by the owner
            {
                dynaProps.OwnerName = rtpStream.Properties.CName;
            }

            return dynaProps;
        }
Example #33
0
        protected PresentationToOneNoteCapability(DynamicProperties dynaProps, string version)
            : base(dynaProps)
        {
            base.isSender = false;
            base.ObjectReceived += new CapabilityObjectReceivedEventHandler(OnObjectReceived);

            // Get OneNote import server
            oneNoteServer = new OneNote.ImportServer();
            importer = (OneNote.ISimpleImporter)oneNoteServer;

            // Get current OneNote notebook directory from Registry
            using (RegistryKey regKey = Registry.CurrentUser.OpenSubKey(
                string.Format(notebookRegKeyPath, version )))
            {
                string notebookPath = (string)regKey.GetValue( notebookRegKeyName );

                if( notebookPath == null || notebookPath == "My Notebook" )
                {
                    oneNoteNotebookDir = Environment.GetFolderPath(System.Environment.SpecialFolder.Personal)
                        + "\\My Notebook";
                }
                else
                {
                    oneNoteNotebookDir = notebookPath;
                }
            }

            if (!Directory.Exists(tfc.BasePath))
                Directory.CreateDirectory(tfc.BasePath);

            // Delete the old log file, if it exists
            if( System.IO.File.Exists("log.xml") )
                System.IO.File.Delete("log.xml");

            // We don't create the blank RTDoc here like Presentation does becuase the
            //  user may decide to open a document, causing the user of OneNote to have
            //  a section with a blank page in it for no purpose.
        }
Example #34
0
 public PresentationToOneNote2007Capability(DynamicProperties dynaProps)
     : base(dynaProps, "12.0")
 {
 }
 public CapabilityDevice(DynamicProperties dynaProps) : base(dynaProps) {}
 public CapabilityDeviceWithWindow(DynamicProperties dynaProps) : base(dynaProps) {}
Example #37
0
 // Required ctor for ICapabilityViewer
 public ChatCapability(DynamicProperties dynaProps) : base(dynaProps) {}
Example #38
0
 protected CapabilityWithWindow(DynamicProperties dynaProps) : base(dynaProps) {}
Example #39
0
        // Required ctor for ICapabilityViewer
        protected Capability(DynamicProperties dynaProps)
        {
            // Read static and overridden properties
            Initialize();

            // Use the properties provided by the capability
            uniqueID = dynaProps.ID;
            name = dynaProps.Name;
            sharedFormID = dynaProps.SharedFormID;
            isChannel = dynaProps.Channel;
            ownerCName = dynaProps.OwnerName;

            isSender = false;
        }
Example #40
0
 public FileTransferCapability(DynamicProperties dp) : base(dp)
 {
     formType = typeof(FileTransferClient);
 }
 /// <summary>
 /// ICapabilityViewer constructor
 /// </summary>
 public SharedBrowser(DynamicProperties dynaProps) : base(dynaProps) {}
 // Required ctor for ICapabilityViewer
 public WhiteboardCapability(DynamicProperties dynaProps) : base(dynaProps) {}
Example #43
0
 public AudioCapability(DynamicProperties dynaProps) : base(dynaProps) 
 {
     RtpStream.FirstFrameReceived += new RtpStream.FirstFrameReceivedEventHandler(RtpStream_FirstFrameReceived);
 }
 // Required ctor for ICapabilityViewer
 public PresenterCapability(DynamicProperties dynaProps)
     : base(dynaProps)
 {
 }