Exemplo n.º 1
0
 public Setting()
 {
     Name         = string.Empty;
     Owner        = string.Empty;
     DefaultValue = new object();
     Value        = new object();
     Scope        = eScope.Application;
 }
Exemplo n.º 2
0
 public Setting(string pName, string pOwner, object pDefaultValue, object pValue, eScope pScope = eScope.Application)
 {
     Name         = pName;
     Owner        = pOwner;
     Scope        = pScope;
     DefaultValue = pDefaultValue;
     Value        = pValue;
 }
Exemplo n.º 3
0
        //public SettingAttribute(string pOwner, string pName, object pDefaultValue, object pValue, eScope pScope = eScope.Application)
        //{
        //    mSetting = new Setting(pOwner, pName, pDefaultValue, pValue, pScope);
        //}

        public SettingAttribute(object pDefaultValue, eScope pScope = eScope.Application)
        {
            DefaultValue = pDefaultValue;
            Scope        = pScope;
        }
Exemplo n.º 4
0
        //public SettingAttribute(string pOwner, string pName, object pDefaultValue, object pValue, eScope pScope = eScope.Application)
        //{
        //    mSetting = new Setting(pOwner, pName, pDefaultValue, pValue, pScope);
        //}

        public SettingAttribute(object pDefaultValue, eScope pScope = eScope.Application)
        {
            DefaultValue = pDefaultValue;
            Scope = pScope;
        }
Exemplo n.º 5
0
        public void WriteSetting <TSetting>(string pOwner, string pName, object pDefaultValue, object pValue, eScope pScope)
        {
            string         fName    = FileName(pOwner);
            List <Setting> Settings = new List <Setting>();

            if (File.Exists(fName))
            {
                Settings = (List <Setting>)(new SharpSerializer()).Deserialize(fName);

                int pos = IndexOf(Settings, s => s.Owner == pOwner && s.Name == pName);
                if (pos != -1)
                {
                    Settings.RemoveAt(pos);
                }
            }
            Setting setting = new Setting(pName, pOwner, pDefaultValue, pValue, pScope);

            //if setting exists remove it from list **************  make one liner


            switch (typeof(TSetting).Name)
            {
            case "Font":
                setting.Value        = (new SerializableFont((Font)pValue));
                setting.DefaultValue = (new SerializableFont((Font)pDefaultValue));
                break;

            case "Color":
                setting.Value        = (new SerializableColor((Color)pValue));
                setting.DefaultValue = (new SerializableColor((Color)pDefaultValue));
                break;
            }

            Settings.Add(setting);

            if (File.Exists(fName))
            {
                File.Delete(fName);
            }

            // adjust for culture
            SharpSerializerXmlSettings xmlSettings = new SharpSerializerXmlSettings();

            xmlSettings.Culture  = System.Globalization.CultureInfo.CurrentCulture;
            xmlSettings.Encoding = System.Text.Encoding.Unicode;
            //Polenter.Serialization.Advanced.PropertyProvider pp = new Polenter.Serialization.Advanced.PropertyProvider();

            //serializer.
            (new SharpSerializer(xmlSettings)).Serialize(Settings, fName);
        }