Example #1
0
        public void InitStructureEnums()
        {
            Console.WriteLine("Initializing Structure Enums...");
            Structure = new Dictionary <string, IEnumerable <MFilesObject> >();

            if (ObjectTypes == null)
            {
                ObjectTypes = new ObjectTypes(DevelopertTool.Vault);
            }
            Structure["Object"] = ObjectTypes;

            if (ClassTypes == null)
            {
                ClassTypes = new ClassTypes(DevelopertTool.Vault);
            }
            Structure["Class"] = ClassTypes;

            if (PropertyDefinitions == null)
            {
                PropertyDefinitions = new PropertyDefinitions(DevelopertTool.Vault);
            }
            Structure["PropertyDefinition"] = PropertyDefinitions;

            if (ValueLists == null)
            {
                ValueLists = new ValueLists(DevelopertTool.Vault);
            }
            // Add later
        }
Example #2
0
        /// <summary>
        /// Define o valor da propriedade do perfil.
        /// </summary>
        /// <param name="propertyName"></param>
        /// <param name="propertyValue"></param>
        public void SetPropertyValue(string propertyName, object propertyValue)
        {
            ProfilePropertyDefinition propertyDefinition = null;

            if (!PropertyDefinitions.TryGetValue(propertyName, out propertyDefinition))
            {
                throw new InvalidOperationException(string.Format("Not found property '{0}' for profile", propertyName));
            }

            string value = null;

            if (propertyValue != null)
            {
                if (propertyValue is IConvertible)
                {
                    value = ((IConvertible)propertyValue).ToString(System.Globalization.CultureInfo.InvariantCulture);
                }
                else
                {
                    value = propertyValue.ToString();
                }
            }

            ProfileProvider.SetProfilePropertyValue(this, propertyDefinition, value);

            lock (_properties)
                if (_properties.ContainsKey(propertyDefinition.Name))
                {
                    _properties[propertyDefinition.Name] = propertyValue;
                }
                else
                {
                    _properties.Add(propertyDefinition.Name, propertyValue);
                }
        }
Example #3
0
        public IListExpression <TRequest, TEntity, TResult> Property <T>(Expression <Func <TRequest, T> > property, Action <IPropertyExpression <TRequest, T, TResult> > action = null)
        {
            var expression = new PropertyExpression <TRequest, T, TResult>(property);

            action?.Invoke(expression);
            PropertyDefinitions.Add(property.GetPropertyInfo(), expression);
            return(this);
        }
Example #4
0
        protected List <IBaseProperty> GetPropDefinitionsByRow(object importRow)
        {
            List <IBaseProperty> l  = new List <IBaseProperty>();
            TemplateMapping      tm = GetTemplateMapping((Item)importRow);

            if (tm == null)
            {
                return(PropertyDefinitions);
            }

            //get the template fields
            List <IBaseProperty> tempProps = tm.PropertyDefinitions;

            //filter duplicates in template fields from global fields
            List <string> names = tempProps.Select(a => a.Name).ToList();

            l.AddRange(tempProps);
            l.AddRange(PropertyDefinitions.Where(a => !names.Contains(a.Name)));

            return(l);
        }
Example #5
0
            public PatternDefinitions()
            {
                Properties = new PropertyDefinitions();

                ManagedAssemblies = new ContentPatternDefinition
                {
                    GroupPatterns =
                    {
                        "runtimes/{rid}/lib/{tfm}/{any?}",
                        "lib/{tfm}/{any?}"
                    },
                    PathPatterns =
                    {
                        "runtimes/{rid}/lib/{tfm}/{assembly}",
                        "lib/{tfm}/{assembly}"
                    },
                    PropertyDefinitions = Properties.Definitions
                };

                ManagedAssemblies.GroupPatterns.Add(new PatternDefinition
                {
                    Pattern = "lib/{assembly?}",
                    Defaults = new Dictionary<string, object>
                    {
                        {  "tfm", VersionUtility.ParseFrameworkName("net") }
                    }
                });

                ManagedAssemblies.PathPatterns.Add(new PatternDefinition
                {
                    Pattern = "lib/{assembly}",
                    Defaults = new Dictionary<string, object>
                    {
                        {  "tfm", VersionUtility.ParseFrameworkName("net") }
                    }
                });

                CompileTimeAssemblies = new ContentPatternDefinition
                {
                    GroupPatterns =
                    {
                        "ref/{tfm}/{any?}",
                    },
                    PathPatterns =
                    {
                        "ref/{tfm}/{assembly}",
                    },
                    PropertyDefinitions = Properties.Definitions,
                };

                ResourceAssemblies = new ContentPatternDefinition
                {
                    GroupPatterns =
                    {
                        "runtimes/{rid}/lib/{tfm}/{locale?}/{any?}",
                        "lib/{tfm}/{locale?}/{any?}"
                    },
                    PathPatterns =
                    {
                        "runtimes/{rid}/lib/{tfm}/{locale}/{resources}",
                        "lib/{tfm}/{locale}/{resources}"
                    },
                    PropertyDefinitions = Properties.Definitions
                };

                ResourceAssemblies.GroupPatterns.Add(new PatternDefinition
                {
                    Pattern = "lib/{locale}/{resources?}",
                    Defaults = new Dictionary<string, object>
                    {
                        {  "tfm", VersionUtility.ParseFrameworkName("net") }
                    }
                });

                ResourceAssemblies.PathPatterns.Add(new PatternDefinition
                {
                    Pattern = "lib/{locale}/{resources}",
                    Defaults = new Dictionary<string, object>
                    {
                        {  "tfm", VersionUtility.ParseFrameworkName("net") }
                    }
                });

                NativeLibraries = new ContentPatternDefinition
                {
                    GroupPatterns =
                    {
                        "runtimes/{rid}/native/{any?}",
                        "native/{any?}",
                    },
                    PathPatterns =
                    {
                        "runtimes/{rid}/native/{any}",
                        "native/{any}",
                    },
                    PropertyDefinitions = Properties.Definitions,
                };
            }
Example #6
0
        public SitecoreDataMap(Database db, string connectionString, Item importItem) : base(db, connectionString, importItem)
        {
            Item fLang = SitecoreDB.GetItem(importItem.Fields["Import From Language"].Value);

            ImportFromLanguage = LanguageManager.GetLanguage(fLang.Name);

            CheckboxField cf = importItem.Fields["Recursively Fetch Children"];

            RecursivelyFetchChildren = cf.Checked;

            //deal with sitecore properties if any
            Item Props = GetItemByTemplate(importItem, PropertiesFolderID);

            if (Props.IsNotNull())
            {
                ChildList c = Props.GetChildren();
                if (c.Any())
                {
                    foreach (Item child in c)
                    {
                        //create an item to get the class / assembly name from
                        BaseMapping bm = new BaseMapping(child);
                        if (!string.IsNullOrEmpty(bm.HandlerAssembly))
                        {
                            if (!string.IsNullOrEmpty(bm.HandlerClass))
                            {
                                //create the object from the class and cast as base field to add it to field definitions
                                IBaseProperty bp = null;
                                try {
                                    bp = (IBaseProperty)Sitecore.Reflection.ReflectionUtil.CreateObject(bm.HandlerAssembly, bm.HandlerClass, new object[] { child });
                                } catch (FileNotFoundException fnfe) {
                                    Log("Error", string.Format("the property:{0} binary {1} specified could not be found", child.Name, bm.HandlerAssembly));
                                }
                                if (bp != null)
                                {
                                    PropertyDefinitions.Add(bp);
                                }
                                else
                                {
                                    Log("Error", string.Format("the property: '{0}' class type {1} could not be instantiated", child.Name, bm.HandlerClass));
                                }
                            }
                            else
                            {
                                Log("Error", string.Format("the property: '{0}' Handler Class {1} is not defined", child.Name, bm.HandlerClass));
                            }
                        }
                        else
                        {
                            Log("Error", string.Format("the property: '{0}' Handler Assembly {1} is not defined", child.Name, bm.HandlerAssembly));
                        }
                    }
                }
                else
                {
                    Log("Warn", "there are no properties to import");
                }
            }

            Item Temps = GetItemByTemplate(importItem, TemplatesFolderID);

            if (Temps.IsNotNull())
            {
                ChildList c = Temps.GetChildren();
                if (c.Any())
                {
                    foreach (Item child in c)
                    {
                        //create an item to get the class / assembly name from
                        TemplateMapping tm = new TemplateMapping(child);
                        if (string.IsNullOrEmpty(tm.FromWhatTemplate))
                        {
                            Log("Error", string.Format("the template mapping field 'FromWhatTemplate' on '{0}' is not defined", child.Name));
                            break;
                        }
                        if (string.IsNullOrEmpty(tm.ToWhatTemplate))
                        {
                            Log("Error", string.Format("the template mapping field 'ToWhatTemplate' on '{0}' is not defined", child.Name));
                            break;
                        }
                        TemplateMappingDefinitions.Add(tm.FromWhatTemplate, tm);
                    }
                }
            }
        }
        public AWS.BOM UpdateProperties(IEnumerable <AWS.PropWriteReq> fileProperties)
        {
            if (BOM == null)
            {
                return(null);
            }
            if ((BOM.CompAttrArray == null) || (BOM.PropArray == null))
            {
                return(BOM);
            }
            AWS.BOMComp comp = BOM.CompArray.FirstOrDefault(c => c.XRefTyp == AWS.XRefTypeEnum.Internal);

            if (comp == null)
            {
                return(BOM);
            }
            if (fileProperties.Any() == false)
            {
                return(BOM);
            }
            List <AWS.BOMProp>     properties = new List <AWS.BOMProp>(BOM.PropArray);
            List <AWS.BOMCompAttr> attributes = new List <AWS.BOMCompAttr>(BOM.CompAttrArray);

            foreach (AWS.PropWriteReq req in fileProperties)
            {
                AWS.BOMProp bomProp = properties.FirstOrDefault(p => string.Equals(p.Moniker, req.Moniker));

                if (bomProp == null)
                {
                    VDF.Vault.Currency.Properties.ContentSourcePropertyMapping definition = PropertyDefinitions.FirstOrDefault(d => string.Equals(d.ContentPropertyDefinition.Moniker, req.Moniker));

                    AWS.BOMProp newProp = new AWS.BOMProp
                    {
                        Id       = properties.Count + 1,
                        DispName = definition.ContentPropertyDefinition.DisplayName,
                        Name     = definition.ContentPropertyDefinition.DisplayName,
                        Moniker  = definition.ContentPropertyDefinition.Moniker,
                        Typ      = DataTypeToPropertyType(definition.ContentPropertyDefinition.DataType),
                    };

                    properties.Add(newProp);
                    bomProp = newProp;
                }
                AWS.BOMCompAttr attr = BOM.CompAttrArray.FirstOrDefault(a => a.PropId == bomProp.Id);

                if (attr == null)
                {
                    AWS.BOMCompAttr newAttr = new AWS.BOMCompAttr
                    {
                        Id     = attributes.Count + 1,
                        CompId = comp.Id,
                        PropId = bomProp.Id,
                        Val    = Convert.ToString(req.Val),
                    };

                    attributes.Add(newAttr);
                    attr = newAttr;
                }
                attr.Val = Convert.ToString(req.Val);
            }
            BOM.CompAttrArray = attributes.ToArray();
            BOM.PropArray     = properties.ToArray();
            return(BOM);
        }
Example #8
0
            public PatternDefinitions()
            {
                Properties = new PropertyDefinitions();

                ManagedAssemblies = new ContentPatternDefinition
                {
                    GroupPatterns =
                    {
                        "runtimes/{rid}/lib/{tfm}/{any?}",
                        "lib/{tfm}/{any?}"
                    },
                    PathPatterns =
                    {
                        "runtimes/{rid}/lib/{tfm}/{assembly}",
                        "lib/{tfm}/{assembly}"
                    },
                    PropertyDefinitions = Properties.Definitions
                };

                ManagedAssemblies.GroupPatterns.Add(new PatternDefinition
                {
                    Pattern  = "lib/{assembly?}",
                    Defaults = new Dictionary <string, object>
                    {
                        { "tfm", VersionUtility.ParseFrameworkName("net") }
                    }
                });

                ManagedAssemblies.PathPatterns.Add(new PatternDefinition
                {
                    Pattern  = "lib/{assembly}",
                    Defaults = new Dictionary <string, object>
                    {
                        { "tfm", VersionUtility.ParseFrameworkName("net") }
                    }
                });

                CompileTimeAssemblies = new ContentPatternDefinition
                {
                    GroupPatterns =
                    {
                        "ref/{tfm}/{any?}",
                    },
                    PathPatterns =
                    {
                        "ref/{tfm}/{assembly}",
                    },
                    PropertyDefinitions = Properties.Definitions,
                };

                ResourceAssemblies = new ContentPatternDefinition
                {
                    GroupPatterns =
                    {
                        "runtimes/{rid}/lib/{tfm}/{locale?}/{any?}",
                        "lib/{tfm}/{locale?}/{any?}"
                    },
                    PathPatterns =
                    {
                        "runtimes/{rid}/lib/{tfm}/{locale}/{resources}",
                        "lib/{tfm}/{locale}/{resources}"
                    },
                    PropertyDefinitions = Properties.Definitions
                };

                ResourceAssemblies.GroupPatterns.Add(new PatternDefinition
                {
                    Pattern  = "lib/{locale}/{resources?}",
                    Defaults = new Dictionary <string, object>
                    {
                        { "tfm", VersionUtility.ParseFrameworkName("net") }
                    }
                });

                ResourceAssemblies.PathPatterns.Add(new PatternDefinition
                {
                    Pattern  = "lib/{locale}/{resources}",
                    Defaults = new Dictionary <string, object>
                    {
                        { "tfm", VersionUtility.ParseFrameworkName("net") }
                    }
                });

                NativeLibraries = new ContentPatternDefinition
                {
                    GroupPatterns =
                    {
                        "runtimes/{rid}/native/{any?}",
                        "native/{any?}",
                    },
                    PathPatterns =
                    {
                        "runtimes/{rid}/native/{any}",
                        "native/{any}",
                    },
                    PropertyDefinitions = Properties.Definitions,
                };
            }
Example #9
0
 public void InitPropertyDefinitions()
 {
     Console.WriteLine("[INFO] Initializing PropertyDefinitions...");
     PropertyDefinitions = new PropertyDefinitions(DevelopertTool.Vault);
 }