public void HomesController_GetPropertyUsingGuid_ReturnPropertyUsingGuid()
        {
            HomesController homesController = new HomesController(_findProperty);
            var             requestType     = homesController.GetProperty(Guid.Parse("6905f139-6705-4ed8-87d7-34b5bc3fb0d6"));
            OkObjectResult  okRequest       = requestType.Result as OkObjectResult;
            IBaseProperty   result          = (IBaseProperty)okRequest.Value;

            Assert.NotNull(result);
        }
コード例 #2
0
        public SitecoreDataMap(Database db, Item importItem, LevelLogger logger)
            : base(db, importItem, logger)
        {
            //deal with sitecore properties if any
            Item Props = GetItemByTemplate(importItem, Utility.Constants.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) {
                                    Logger.AddError("Error", string.Format("the property:{0} binary {1} specified could not be found", child.Name, bm.HandlerAssembly));
                                }
                                if (bp != null)
                                {
                                    PropertyDefinitions.Add(bp);
                                }
                                else
                                {
                                    Logger.AddError("Error", string.Format("the property: '{0}' class type {1} could not be instantiated", child.Name, bm.HandlerClass));
                                }
                            }
                            else
                            {
                                Logger.AddError("Error", string.Format("the property: '{0}' Handler Class {1} is not defined", child.Name, bm.HandlerClass));
                            }
                        }
                        else
                        {
                            Logger.AddError("Error", string.Format("the property: '{0}' Handler Assembly {1} is not defined", child.Name, bm.HandlerAssembly));
                        }
                    }
                }
                else
                {
                    Logger.AddError("Warn", "there are no properties to import");
                }
            }
        }
        public ActionResult <IBaseProperty> GetProperty(Guid id)
        {
            if (id == null)
            {
                return(BadRequest());
            }
            IBaseProperty baseProperty = _findProperty.GetBaseProperty(id);

            if (baseProperty == null)
            {
                return(BadRequest("Unkown property id"));
            }
            return(Ok(baseProperty));
        }
コード例 #4
0
ファイル: SitecoreDataMap.cs プロジェクト: jayasimhas/Suseela
        protected List <IBaseProperty> GetPropDefinitions(Item i)
        {
            List <IBaseProperty> l = new List <IBaseProperty>();

            //check for properties folder
            Item Props = i.GetChildByTemplate(PropertiesFolderTemplateID);

            if (Props.IsNull())
            {
                Logger.Log("Warn", string.Format("there is no 'Properties' folder on '{0}'", i.DisplayName));
                return(l);
            }

            //check for any children
            if (!Props.HasChildren)
            {
                Logger.Log("Warn", string.Format("there are no properties to import on '{0}'", i.DisplayName));
                return(l);
            }

            ChildList c = Props.GetChildren();

            foreach (Item child in c)
            {
                //create an item to get the class / assembly name from
                BaseMapping bm = new BaseMapping(child);

                //check for assembly
                if (string.IsNullOrEmpty(bm.HandlerAssembly))
                {
                    Logger.Log(child.Paths.FullPath, "the 'Handler Assembly' is not defined", ProcessStatus.ImportDefinitionError, "Handler Assembly", bm.HandlerAssembly);
                    continue;
                }

                //check for class
                if (string.IsNullOrEmpty(bm.HandlerClass))
                {
                    Logger.Log(child.Paths.FullPath, "the Handler Class is not defined", ProcessStatus.ImportDefinitionError, "Handler Class", bm.HandlerClass);
                    continue;
                }

                //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) {
                    Logger.Log(child.Paths.FullPath, "the binary could not be found", ProcessStatus.ImportDefinitionError, "Handler Assembly", bm.HandlerAssembly);
                }

                if (bp != null)
                {
                    l.Add(bp);
                }
                else
                {
                    Logger.Log(child.Paths.FullPath, "the class type could not be instantiated", ProcessStatus.ImportDefinitionError, "Handler Class", bm.HandlerClass);
                }
            }

            return(l);
        }
コード例 #5
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);
                    }
                }
            }
        }
コード例 #6
0
        public void CSVService_GetBasePropertyUsingInccorectGUID_ReturnANull()
        {
            IBaseProperty result = _findProperty.GetBaseProperty(Guid.NewGuid());

            Assert.Null(result);
        }
コード例 #7
0
        public void CSVService_GetBasePropertyUsingGUID_ReturnsASingleProperty()
        {
            IBaseProperty result = _findProperty.GetBaseProperty(Guid.Parse("0788743a-c729-4d1b-9c8f-626ae48a0134"));

            Assert.NotNull(result);
        }