示例#1
0
    /// <summary>
    /// Get the value of a Parameter
    /// </summary>
    /// <param name="parameter">UmbracoType</param>
    /// <returns>Returns the parameter if exists, if not returns an empty string</returns>
    public static string GetParameterValue(UmbracoType parameter)
    {
        string result = string.Empty;

        switch (parameter)
        {
        case UmbracoType.Connection:
            result = ConfigurationManager.ConnectionStrings["umbracoDbDSN"].ConnectionString;
            break;

        case UmbracoType.TimeOut:
            result = ConfigurationManager.AppSettings["umbracoTimeOutInMinutes"];
            break;

        default:
            //string path = HttpContext.Current != null ? HttpContext.Current.Server.MapPath("~/App_Data") + @"\ResourceData.xml" : ConfigurationManager.AppSettings["ResourceData"];
            string    path        = ConfigurationManager.AppSettings["ResourceData"];
            XDocument umbracoData = XDocument.Load(path);
            result = (from c in umbracoData.Descendants("Data")
                      where c.Value.Equals(parameter.ToString())
                      select c.Attribute("key").Value).FirstOrDefault();
            break;
        }
        return(result);
    }
示例#2
0
    /// <summary>
    /// Get a List of PreValues by Id
    /// </summary>
    /// <param name="parameter">UmbracoType</param>
    /// <returns>List of PreValues</returns>
    public static IEnumerable <PreValue> DataTypeValue(UmbracoType parameter)
    {
        int id = Convert.ToInt32(GetParameterValue(parameter));
        DataTypeDefinition dataTypeDefinition = DataTypeDefinition.GetDataTypeDefinition(id);
        SortedList         data = PreValues.GetPreValues(dataTypeDefinition.Id);

        return(data.Values.Cast <PreValue>());
    }
示例#3
0
    /// <summary>
    /// Return Id of a PreValue
    /// </summary>
    /// <param name="parameter">UmbracoType</param>
    /// <param name="value">value as a string</param>
    /// <returns>Returns the id of the Property if exists, if not returns 0</returns>
    public static int PropertyId(UmbracoType parameter, string value)
    {
        int id = Convert.ToInt32(GetParameterValue(parameter));
        IEnumerable <PreValue> data = DataTypeValue(id);
        PreValue preValue           = data.SingleOrDefault(dt => dt.Value.ToLower() == value.ToLower());

        return((preValue != null) ? preValue.Id : 0);
    }
示例#4
0
    /// <summary>
    /// Return a value of a PreValue by value
    /// </summary>
    /// <param name="parameter">UmbracoType</param>
    /// <param name="preValueId">id of the PreValue</param>
    /// <returns>Returns the value of the PreValue if exists, if not returns an empty string</returns>
    public static string PropertyValue(UmbracoType parameter, int preValueId)
    {
        int id = Convert.ToInt32(GetParameterValue(parameter));
        IEnumerable <PreValue> data = DataTypeValue(id);
        PreValue preValue           = data.SingleOrDefault(dt => dt.Id == preValueId);
        string   result             = (preValue != null) ? preValue.Value : string.Empty;

        return(result);
    }
示例#5
0
    /// <summary>
    /// Add new value to a existing PreValue
    /// </summary>
    /// <param name="parameter">UmbracoType</param>
    /// <param name="value">value as a string</param>
    public static void SetPreValue(UmbracoType parameter, string value)
    {
        int id = Convert.ToInt32(GetParameterValue(parameter));
        IEnumerable <PreValue> preValues = DataTypeValue(id);
        PreValue preValue = PreValue.MakeNew(id, value);

        preValue.DataTypeId = id;
        preValue.SortOrder  = preValues.Max(pv => pv.SortOrder) + 1;
        preValue.Save();
    }
        /// <summary>
        /// Imports another map from the configuration
        /// </summary>
        /// <typeparam name="TK"></typeparam>
        protected override void ImportMap <TK>()
        {
            UmbracoType <TK> typeConfig = GetUmbracoType <TK>();

            if (typeConfig == null)
            {
                return;
            }

            GlassType.Import(typeConfig);
        }
示例#7
0
    /// <summary>
    /// Return the Value of a PreValue by object
    /// </summary>
    /// <param name="parameter">UmbracoType</param>
    /// <param name="value">value as a object</param>
    /// <returns>Returns the value of the Property if exists, if not returns an empty string</returns>
    public static string PropertyValue(UmbracoType parameter, object value)
    {
        string result = string.Empty;

        if (DBNull.Value != value)
        {
            int pvalue = Convert.ToInt32(value);
            int id     = Convert.ToInt32(GetParameterValue(parameter));
            IEnumerable <PreValue> data = DataTypeValue(id);
            PreValue preValue           = data.SingleOrDefault(dt => dt.Id == pvalue);
            result = (preValue != null) ? preValue.Value : string.Empty;
        }
        return(result);
    }
示例#8
0
 /// <summary>
 /// Add new value to a existing PreValue
 /// </summary>
 /// <param name="parameter">UmbracoType</param>
 /// <param name="value">value as a string</param>
 public static void SetPreValue(UmbracoType parameter, string value)
 {
     int id = Convert.ToInt32(GetParameterValue(parameter));
     IEnumerable<PreValue> preValues = DataTypeValue(id);
     PreValue preValue = PreValue.MakeNew(id, value);
     preValue.DataTypeId = id;
     preValue.SortOrder = preValues.Max(pv => pv.SortOrder) + 1;
     preValue.Save();
 }
示例#9
0
    /// <summary>
    /// Return the id of a PreValue by value
    /// </summary>
    /// <param name="parameter">UmbracoType</param>
    /// <param name="value">value as a string</param>
    /// <returns>Returns the value of the PreValue if exists, if not returns an empty string</returns>
    public static int PropertyValueId(UmbracoType parameter, string value)
    {
        int id = Convert.ToInt32(GetParameterValue(parameter));
        IEnumerable<PreValue> data = DataTypeValue(id);
        PreValue preValue = data.SingleOrDefault(dt => dt.Value.ToLower() == value.ToLower());
        int result = (preValue != null) ? preValue.Id : 0;

        return result;
    }
示例#10
0
 /// <summary>
 /// Return the Value of a PreValue by object
 /// </summary>
 /// <param name="parameter">UmbracoType</param>
 /// <param name="value">value as a object</param>
 /// <returns>Returns the value of the Property if exists, if not returns an empty string</returns>
 public static string PropertyValue(UmbracoType parameter, object value)
 {
     string result = string.Empty;
     if (DBNull.Value != value)
     {
         int pvalue = Convert.ToInt32(value);
         int id = Convert.ToInt32(GetParameterValue(parameter));
         IEnumerable<PreValue> data = DataTypeValue(id);
         PreValue preValue = data.SingleOrDefault(dt => dt.Id == pvalue);
         result = (preValue != null) ? preValue.Value : string.Empty;
     }
     return result;
 }
示例#11
0
    /// <summary>
    /// Return a value of a PreValue by value
    /// </summary>
    /// <param name="parameter">UmbracoType</param>
    /// <param name="preValueId">id of the PreValue</param>
    /// <returns>Returns the value of the PreValue if exists, if not returns an empty string</returns>
    public static string PropertyValue(UmbracoType parameter, int preValueId)
    {
        int id = Convert.ToInt32(GetParameterValue(parameter));
        IEnumerable<PreValue> data = DataTypeValue(id);
        PreValue preValue = data.SingleOrDefault(dt => dt.Id == preValueId);
        string result = (preValue != null) ? preValue.Value : string.Empty;

        return result;
    }
示例#12
0
 /// <summary>
 /// Get the value of a Parameter
 /// </summary>
 /// <param name="parameter">UmbracoType</param>
 /// <returns>Returns the parameter if exists, if not returns an empty string</returns>
 public static string GetParameterValue(UmbracoType parameter)
 {
     string result = string.Empty;
     switch (parameter)
     {
         case UmbracoType.Connection:
             result = ConfigurationManager.ConnectionStrings["umbracoDbDSN"].ConnectionString;
             break;
         case UmbracoType.TimeOut:
             result = ConfigurationManager.AppSettings["umbracoTimeOutInMinutes"];
             break;
         default:
             //string path = HttpContext.Current != null ? HttpContext.Current.Server.MapPath("~/App_Data") + @"\ResourceData.xml" : ConfigurationManager.AppSettings["ResourceData"];
             string path = ConfigurationManager.AppSettings["ResourceData"];
             XDocument umbracoData = XDocument.Load(path);
             result = (from c in umbracoData.Descendants("Data")
                       where c.Value.Equals(parameter.ToString())
                       select c.Attribute("key").Value).FirstOrDefault();
             break;
     }
     return result;
 }
示例#13
0
 /// <summary>
 /// Get a List of PreValues by Id
 /// </summary>
 /// <param name="parameter">UmbracoType</param>
 /// <returns>List of PreValues</returns>
 public static IEnumerable<PreValue> DataTypeValue(UmbracoType parameter)
 {
     int id = Convert.ToInt32(GetParameterValue(parameter));
     DataTypeDefinition dataTypeDefinition = DataTypeDefinition.GetDataTypeDefinition(id);
     SortedList data = PreValues.GetPreValues(dataTypeDefinition.Id);
     return data.Values.Cast<PreValue>();
 }