public static string GetComponentLinkedValue(this IFieldSet fields, string schemaFieldName, bool isLinkedFieldMetadata,
                                              string componentFieldName)
 {
     if (fields.ContainsKey(schemaFieldName))
     {
         if (fields[schemaFieldName].LinkedComponentValues.Count > 0)
         {
             var linkedComponent = fields[schemaFieldName].LinkedComponentValues[0];
             if (isLinkedFieldMetadata)
             {
                 if (linkedComponent.MetadataFields.ContainsKey(componentFieldName))
                 {
                     return(linkedComponent.MetadataFields.GetValue(componentFieldName));
                 }
             }
             else
             {
                 if (linkedComponent.Fields.ContainsKey(componentFieldName))
                 {
                     return(linkedComponent.Fields.GetValue(componentFieldName));
                 }
             }
         }
     }
     return(string.Empty);
 }
 public override IEnumerable<string> GetMultiValue(IFieldSet fields)
 {
     var result = new List<MvcHtmlString>();
     if (fields.ContainsKey(SchemaFieldName))
     {
         result.AddRange(fields[SchemaFieldName].Values.Select(item => item.ResolveRichText()));
     }
     return result.Select(x=>x.ToString());
 }
 public override string GetValue(IFieldSet fields)
 {
     var result = new StringBuilder();
     if (fields.ContainsKey(SchemaFieldName))
     {
         string value = fields[SchemaFieldName].Value;
         result.Append(value.ResolveRichText());
     }
     return result.ToString();
 }
Ejemplo n.º 4
0
        public override IEnumerable <string> GetMultiValue(IFieldSet fields, IPage page = null)
        {
            var result = new List <MvcHtmlString>();

            if (fields.ContainsKey(SchemaFieldName))
            {
                result.AddRange(fields[SchemaFieldName].Values.Select(item => item.ResolveRichText(page)));
            }
            return(result.Select(x => x.ToString()));
        }
        public static IEnumerable <string> GetMultiValue(this IFieldSet fields, string schemaFieldName)
        {
            var result = new List <string>();

            if (fields.ContainsKey(schemaFieldName))
            {
                return(fields[schemaFieldName].Values);
            }
            return(result);
        }
        public static string GetValue(this IFieldSet fields, string schemaFieldName)
        {
            var result = new StringBuilder();

            if (fields.ContainsKey(schemaFieldName))
            {
                result.Append(fields[schemaFieldName].Value);
            }
            return(result.ToString());
        }
Ejemplo n.º 7
0
        private IField GetField(IFieldSet fields, IModelProperty fieldProp)
        {
            IField result = null;

            if (fieldProp.PropertyAttribute is IFieldAttribute)
            {
                var fieldName = ((IFieldAttribute)fieldProp.PropertyAttribute).FieldName;
                result = fields.ContainsKey(fieldName) ? fields[fieldName] : null;
            }
            return(result);
        }
Ejemplo n.º 8
0
        public override string GetValue(IFieldSet fields, IPage page = null)
        {
            var result = new StringBuilder();

            if (fields.ContainsKey(SchemaFieldName))
            {
                string value = fields[SchemaFieldName].Value;
                result.Append(value.ResolveRichText(page));
            }
            return(result.ToString());
        }
 public static IComponent GetLinkedComponent(this IFieldSet fields, string schemaFieldName)
 {
     if (fields.ContainsKey(schemaFieldName))
     {
         if (fields[schemaFieldName].LinkedComponentValues.Count > 0)
         {
             return(fields[schemaFieldName].LinkedComponentValues[0]);
         }
     }
     return(null);
 }
 public static string GetKeywordUriValue(this IFieldSet fields, string schemaFieldName)
 {
     if (fields.ContainsKey(schemaFieldName))
     {
         if (fields[schemaFieldName].Keywords.Count > 0)
         {
             return(fields[schemaFieldName].Keywords[0].Id);
         }
     }
     return(null);
 }
 public static IEnumerable <double> GetNumberMultiValue(this IFieldSet fields, string schemaFieldName)
 {
     if (fields.ContainsKey(schemaFieldName))
     {
         if (fields[schemaFieldName].NumericValues.Count > 0)
         {
             return(fields[schemaFieldName].NumericValues);
         }
     }
     return(new List <double>());
 }
 public static IEnumerable <DateTime> GetDateTimeMultiValue(this IFieldSet fields, string schemaFieldName)
 {
     if (fields.ContainsKey(schemaFieldName))
     {
         if (fields[schemaFieldName].DateTimeValues.Count > 0)
         {
             return(fields[schemaFieldName].DateTimeValues);
         }
     }
     return(new List <DateTime>());
 }
 public static IEnumerable <IComponent> GetLinkedComponentMultiValue(this IFieldSet fields, string schemaFieldName)
 {
     if (fields.ContainsKey(schemaFieldName))
     {
         if (fields[schemaFieldName].LinkedComponentValues.Count > 0)
         {
             return(fields[schemaFieldName].LinkedComponentValues);
         }
     }
     return(new List <IComponent>());
 }
 public static IEnumerable <IFieldSet> GetEmbeddedFieldSetMultiValue(this IFieldSet fields, string schemaFieldName)
 {
     if (fields.ContainsKey(schemaFieldName))
     {
         if (fields[schemaFieldName].EmbeddedValues.Count > 0)
         {
             return(fields[schemaFieldName].EmbeddedValues);
         }
     }
     return(new List <IFieldSet>());
 }
 public static DateTime GetDateTimeValue(this IFieldSet fields, string schemaFieldName)
 {
     if (fields.ContainsKey(schemaFieldName))
     {
         if (fields[schemaFieldName].DateTimeValues.Count > 0)
         {
             return(fields[schemaFieldName].DateTimeValues[0]);
         }
     }
     return(DateTime.MinValue);
 }
 public static IFieldSet GetEmbeddedFieldSet(this IFieldSet fields, string schemaFieldName)
 {
     if (fields.ContainsKey(schemaFieldName))
     {
         if (fields[schemaFieldName].EmbeddedValues.Count > 0)
         {
             return(fields[schemaFieldName].EmbeddedValues[0]);
         }
     }
     return(null);
 }
 public static IEnumerable <IKeyword> GetLinkedKeywordMultiValue(this IFieldSet fields, string schemaFieldName)
 {
     if (fields.ContainsKey(schemaFieldName))
     {
         if (fields[schemaFieldName].Keywords.Count > 0)
         {
             return(fields[schemaFieldName].Keywords);
         }
     }
     return(new List <IKeyword>());
 }
 public static IKeyword GetLinkedKeyword(this IFieldSet fields, string schemaFieldName)
 {
     if (fields.ContainsKey(schemaFieldName))
     {
         if (fields[schemaFieldName].Keywords.Count > 0)
         {
             return(fields[schemaFieldName].Keywords[0]);
         }
     }
     return(null);
 }
        public static double GetNumberValue(this IFieldSet fields, string schemaFieldName)
        {
            if (fields.ContainsKey(schemaFieldName))
            {
                if (fields[schemaFieldName].NumericValues.Count > 0)
                {
                    return(fields[schemaFieldName].NumericValues[0]);
                }
            }

            return(default(double));
        }
 public override IEnumerable<string> GetMultiValue(IFieldSet fields, IPage page = null)
 {
     var result = new List<string>();
     if (fields.ContainsKey(SchemaFieldName))
     {
         foreach(var linkedComponent in fields[SchemaFieldName].LinkedComponentValues)
         {
             string value = linkedComponent.Fields.GetValue(ComponentFieldName);
             result.Add(value.RemoveNamespacesAndWrapInParagraph().ResolveRichText(page).ToString());
         }
     }
     return result;
 }
 public override string GetValue(IFieldSet fields, IPage page = null)
 {
     var stringBuilder = new StringBuilder();
     if (fields.ContainsKey(SchemaFieldName))
     {
         if (fields[SchemaFieldName].LinkedComponentValues.Count > 0)
         {
             var linkedComponent = fields[SchemaFieldName].LinkedComponentValues[0];
             stringBuilder.Append(linkedComponent.Multimedia.Url);
         }
     }
     return stringBuilder.ToString();
 }
Ejemplo n.º 22
0
        public override string GetValue(IFieldSet fields, IPage page = null)
        {
            var stringBuilder = new StringBuilder();

            if (fields.ContainsKey(SchemaFieldName))
            {
                if (fields[SchemaFieldName].LinkedComponentValues.Count > 0)
                {
                    var linkedComponent = fields[SchemaFieldName].LinkedComponentValues[0];
                    stringBuilder.Append(linkedComponent.Multimedia.Url);
                }
            }
            return(stringBuilder.ToString());
        }
        public override IEnumerable <string> GetMultiValue(IFieldSet fields, IPage page = null)
        {
            var result = new List <string>();

            if (fields.ContainsKey(SchemaFieldName))
            {
                foreach (var linkedComponent in fields[SchemaFieldName].LinkedComponentValues)
                {
                    string value = linkedComponent.Fields.GetValue(ComponentFieldName);
                    result.Add(value.RemoveNamespacesAndWrapInParagraph().ResolveRichText(page).ToString());
                }
            }
            return(result);
        }
 public override IEnumerable<string> GetMultiValue(IFieldSet fields, IPage page = null)
 {
     List<string> values = new List<string>();
     if(fields.ContainsKey(SchemaFieldName))
     {
         var linkedComponent = fields[SchemaFieldName].LinkedComponentValues[0];
         
         if (linkedComponent.Fields.ContainsKey(ComponentFieldName))
         {
             return linkedComponent.Fields[ComponentFieldName].LinkedComponentValues.Select(x=>x.Multimedia.Url);
         }
         
     }
     return values;
 }
        public override IEnumerable <string> GetMultiValue(IFieldSet fields, IPage page = null)
        {
            List <string> values = new List <string>();

            if (fields.ContainsKey(SchemaFieldName))
            {
                var linkedComponent = fields[SchemaFieldName].LinkedComponentValues[0];

                if (linkedComponent.Fields.ContainsKey(ComponentFieldName))
                {
                    return(linkedComponent.Fields[ComponentFieldName].LinkedComponentValues.Select(x => x.Multimedia.Url));
                }
            }
            return(values);
        }
 public override string GetValue(IFieldSet fields, IPage page = null)
 {
     if (fields.ContainsKey(SchemaFieldName))
     {
         if (fields[SchemaFieldName].LinkedComponentValues.Count > 0)
         {
             var linkedComponent = fields[SchemaFieldName].LinkedComponentValues[0];
             if(linkedComponent.Fields.ContainsKey(ComponentFieldName))
             {
                 return linkedComponent.Fields[ComponentFieldName].LinkedComponentValues[0].Multimedia.Url;
             }
         }
     }
     return string.Empty;
 }
 public override string GetValue(IFieldSet fields, IPage page = null)
 {
     if (fields.ContainsKey(SchemaFieldName))
     {
         if (fields[SchemaFieldName].LinkedComponentValues.Count > 0)
         {
             var linkedComponent = fields[SchemaFieldName].LinkedComponentValues[0];
             if (linkedComponent.Fields.ContainsKey(ComponentFieldName))
             {
                 return(linkedComponent.Fields[ComponentFieldName].LinkedComponentValues[0].Multimedia.Url);
             }
         }
     }
     return(string.Empty);
 }
        public static List <string> GetKeywordUriMultiValue(this IFieldSet fields, string schemaFieldName)
        {
            var result = new List <string>();

            if (fields.ContainsKey(schemaFieldName))
            {
                if (fields[schemaFieldName].Keywords.Count > 0)
                {
                    foreach (var keyword in fields[schemaFieldName].Keywords)
                    {
                        result.Add(keyword.Id);
                    }
                }
            }
            return(result);
        }
 public override IEnumerable<string> GetMultiValue(IFieldSet source, IPage page = null)
 {
     var values = new List<string>();
     if(source.ContainsKey(SchemaFieldName))
     {
         foreach(var linkedComponent in source[SchemaFieldName].LinkedComponentValues)
         {
             values.Add(linkedComponent.Multimedia.Url);
         }
     }
     else if(SchemaFieldName == "" && source.Count > 0)
     {
         foreach (var linkedComponent in source.First().Value.LinkedComponentValues)
         {
             values.Add(linkedComponent.Multimedia.Url);
         }
     }
     return values;
 }
Ejemplo n.º 30
0
        public override IEnumerable <string> GetMultiValue(IFieldSet source, IPage page = null)
        {
            var values = new List <string>();

            if (source.ContainsKey(SchemaFieldName))
            {
                foreach (var linkedComponent in source[SchemaFieldName].LinkedComponentValues)
                {
                    values.Add(linkedComponent.Multimedia.Url);
                }
            }
            else if (SchemaFieldName == "" && source.Count > 0)
            {
                foreach (var linkedComponent in source.First().Value.LinkedComponentValues)
                {
                    values.Add(linkedComponent.Multimedia.Url);
                }
            }
            return(values);
        }
        public static IEnumerable <string> GetComponentLinkedMultiValue(this IFieldSet fields, string schemaFieldName,
                                                                        bool isLinkedFieldMetadata, string componentFieldName)
        {
            var result = new List <string>();

            if (fields.ContainsKey(schemaFieldName))
            {
                foreach (var linkedComponent in fields[schemaFieldName].LinkedComponentValues)
                {
                    if (isLinkedFieldMetadata)
                    {
                        result.Add(linkedComponent.MetadataFields.GetValue(componentFieldName));
                    }
                    else
                    {
                        result.Add(linkedComponent.Fields.GetValue(componentFieldName));
                    }
                }
            }

            return(result);
        }
Ejemplo n.º 32
0
 public static T Field <T>(this IFieldSet fields, string name, Func <IField, T> func)
 {
     return(null != fields && fields.ContainsKey(name) ? func(fields[name]) : default(T));
 }
Ejemplo n.º 33
0
 public static IEnumerable <T> Field <T>(this IFieldSet fields, string name, Func <IField, IEnumerable <T> > func)
 {
     return(null != fields && fields.ContainsKey(name) ? func(fields[name]) : Enumerable.Empty <T>());
 }
Ejemplo n.º 34
0
        public override IEnumerable GetPropertyValues(IModel modelData, IModelProperty property, IViewModelFactory factory)
        {
            IEnumerable result = null;

            if (modelData != null)
            {
                //need null checks on Template
                IFieldSet fields   = null;
                ITemplate template = null;
                if (IsTemplateMetadata)
                {
                    if (modelData is IComponentPresentation)
                    {
                        var templateData = modelData as IComponentPresentation;
                        template = templateData.ComponentTemplate;
                    }
                    else if (modelData is IPage)
                    {
                        var templateData = modelData as IPage;
                        template = templateData.PageTemplate;
                    }
                    fields = template != null ? template.MetadataFields : null;
                }
                else if (IsMetadata)
                {
                    if (modelData is IComponentPresentation)
                    {
                        fields = (modelData as IComponentPresentation).Component.MetadataFields;
                    }
                    else if (modelData is IComponent)
                    {
                        fields = (modelData as IComponent).MetadataFields;
                    }
                    else if (modelData is IPage)
                    {
                        fields = (modelData as IPage).MetadataFields;
                    }
                    else if (modelData is ITemplate)
                    {
                        fields = (modelData as ITemplate).MetadataFields;
                    }
                    else if (modelData is IKeyword)
                    {
                        fields = (modelData as IKeyword).MetadataFields;
                    }
                    //Any other things with MetadataFields?
                }
                else if (modelData is IComponentPresentation)
                {
                    fields = (modelData as IComponentPresentation).Component.Fields;
                }
                else if (modelData is IEmbeddedFields)
                {
                    fields = (modelData as IEmbeddedFields).Fields;
                }
                if (String.IsNullOrEmpty(FieldName))
                {
                    FieldName = GetFieldName(property.Name);                                  //Convention over configuration by default -- Field name = Property name
                }
                if (fields != null && fields.ContainsKey(FieldName))
                {
                    result = this.GetFieldValues(fields[FieldName], property, template, factory);
                }
            }
            return(result);
        }
        private static IField ExtractMatchedField(SemanticSchemaField matchingField, IFieldSet fields, int embedLevel, string path = null)
        {
            if (path==null)
            {
                path = matchingField.Path;
                while (embedLevel >= -1 && path.Contains("/"))
                {
                    int pos = path.IndexOf("/", StringComparison.Ordinal);
                    path = path.Substring(pos+1);
                    embedLevel--;
                }
            }
            string[] bits = path.Split('/');
            if (fields.ContainsKey(bits[0]))
            {
                if (bits.Length > 1)
                {
                    int pos = path.IndexOf("/", StringComparison.Ordinal);
                    return ExtractMatchedField(matchingField, fields[bits[0]].EmbeddedValues[0], embedLevel, path.Substring(pos + 1));
                }

                return fields[bits[0]];
            }
            return null;
        }