コード例 #1
0
        public void Test_CreateUpdateDeleteThread()
        {
            ContentPlaceholderGroup contentPlaceholderGroup = Test_ContentPlaceholderGroup.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.Random);
            ContentPlaceholder      contentPlaceholder      = Test_ContentPlaceholders.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, contentPlaceholderGroup, this.Random);

            ContentPlaceholderHistoryManager manager = new ContentPlaceholderHistoryManager(this.DataStore);
            ContentPlaceholderHistory        record  = Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, contentPlaceholder, this.Random);

            ContentPlaceholderHistory recordToCompare;

            for (int i = 0; i < this.DefaultUpdateTestIterations; i++)
            {
                PopulateWithRandomValues(record, this.DummyDataManager, this.Random);
                recordToCompare = record;

                manager.Update(record);
                record = manager.GetContentPlaceholderHistory(record.ContentPlaceholderHistoryId);

                string errors = string.Empty;
                // TODO (Roman): relax datetime comparisons
                Assert.IsTrue(DebugUtility.ArePropertyValuesEqual(record, recordToCompare, out errors), errors);
                Trace.WriteLine("Update test successfull.");
            }

            Delete(this.DataStore, record);
            Test_ContentPlaceholders.Delete(this.DataStore, contentPlaceholder);
            Test_ContentPlaceholderGroup.Delete(this.DataStore, contentPlaceholderGroup);
        }
コード例 #2
0
 internal static void PopulateWithRandomValues(ContentPlaceholder record, DummyDataManager dtm, Random random)
 {
     record.Name        = "TestContentPlaceholder " + random.Next(1000000, 10000000);
     record.Description = "Description " + random.Next(1000000, 10000000);
     record.IsActive    = DebugUtility.FlipCoin(random);
     record.IsModerated = DebugUtility.FlipCoin(random);
 }
コード例 #3
0
ファイル: BlockComposer.cs プロジェクト: systembugtj/bookasa
 internal Row(
     ContentPlaceholder container,
     float y
     )
 {
     this.Container = container;
     this.Y         = y;
 }
コード例 #4
0
 internal Row(
     ContentPlaceholder container,
     double y
     )
 {
     this.Container = container;
     this.Y         = y;
 }
コード例 #5
0
        internal static void Delete(IDataStore dataStore, ContentPlaceholder contentPlaceholder)
        {
            ContentPlaceholderManager manager = new ContentPlaceholderManager(dataStore);

            BusinessObjectActionReport <DataRepositoryActionStatus> report = manager.Delete(contentPlaceholder);

            Assert.AreEqual(DataRepositoryActionStatus.Success, report.Status);
            Assert.IsNull(manager.GetContentPlaceholder(contentPlaceholder.ContentPlaceholderId));

            Trace.WriteLine("Successfully deleted contentPlaceholder " + contentPlaceholder.Name);
        }
コード例 #6
0
ファイル: Test_ContentBlocks.cs プロジェクト: tm011064/Luputa
        public void Test_CreateUpdateDeleteContentBlock()
        {
            IUserBasic userBasic = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager);
            ContentPlaceholderGroup   contentPlaceholderGroup   = Test_ContentPlaceholderGroup.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.Random);
            ContentPlaceholder        contentPlaceholder        = Test_ContentPlaceholders.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, contentPlaceholderGroup, this.Random);
            ContentPlaceholderHistory contentPlaceholderHistory = Test_ContentPlaceholderHistorys.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, contentPlaceholder, this.Random);

            ContentBlockManager manager = new ContentBlockManager(this.DataStore);
            ContentBlock        record  = Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, userBasic, contentPlaceholderHistory, this.Random);

            Delete(this.DataStore, record);
            Test_ContentPlaceholders.Delete(this.DataStore, contentPlaceholder);
            Test_ContentPlaceholderGroup.Delete(this.DataStore, contentPlaceholderGroup);
        }
コード例 #7
0
        internal static ContentPlaceholder Create(IDataStore dataStore, IApplicationSettings applicationSettings, IApplication application, ContentPlaceholderGroup contentPlaceholderGroup, Random random)
        {
            ContentPlaceholderManager manager = new ContentPlaceholderManager(dataStore);

            ContentPlaceholder contentPlaceholder = new ContentPlaceholder(
                application.ApplicationId
                , contentPlaceholderGroup
                , "TestContentPlaceholder " + random.Next(1000000, 10000000));

            BusinessObjectActionReport <DataRepositoryActionStatus> report = manager.Create(contentPlaceholder);

            Assert.AreEqual(DataRepositoryActionStatus.Success, report.Status);
            Assert.Greater(contentPlaceholder.ContentPlaceholderId, 0);

            ContentPlaceholder dsContentPlaceholder = manager.GetContentPlaceholder(contentPlaceholder.ContentPlaceholderId);

            Assert.IsNotNull(dsContentPlaceholder);

            return(dsContentPlaceholder);
        }
コード例 #8
0
 public BusinessObjectActionReport <DataRepositoryActionStatus> Delete(ContentPlaceholder contentPlaceholder)
 {
     return(_CMSSectionManager.Delete(contentPlaceholder.CMSSection, false));
 }
コード例 #9
0
ファイル: ViewData.cs プロジェクト: rahmanazhar/SpiritCatcher
        /// <summary>
        /// Creates view of specified type.
        /// </summary>
        public static View CreateView(string viewName, View layoutParent, View parent, ValueConverterContext context = null, string theme = "", string id = "", string style = "", IEnumerable <XElement> contentXuml = null)
        {
            // Creates the views in the following order:
            // CreateView(view)
            //   Foreach child
            //     CreateView(child)
            //     SetViewValues(child)
            //   Foreach contentView
            //      CreateView(contentView)
            //      SetViewValues(contentView)
            //   SetViewValues(view)
            //   SetThemeValues(view)

            // TODO store away and re-use view templates

            // use default theme if no theme is specified
            if (String.IsNullOrEmpty(theme))
            {
                theme = ViewPresenter.Instance.DefaultTheme;
            }

            // initialize value converter context
            if (context == null)
            {
                context = ValueConverterContext.Default;
            }

            // create view from XUML
            var viewTypeData = GetViewTypeData(viewName);

            if (viewTypeData == null)
            {
                return(null);
            }

            // get view type
            var viewType = GetViewType(viewName);

            if (viewType == null)
            {
                viewType = typeof(View);
            }

            // create view game object with required components
            var go = new GameObject(viewTypeData.ViewName);

            if (typeof(UIView).IsAssignableFrom(viewType))
            {
                go.AddComponent <RectTransform>();
            }
            go.transform.SetParent(layoutParent.transform, false);

            // create view behavior and initialize it
            var view = go.AddComponent(viewType) as View;

            view.LayoutParent          = layoutParent;
            view.Parent                = parent;
            view.Id                    = id;
            view.Style                 = style;
            view.Theme                 = theme;
            view.Content               = view;
            view.ViewXumlName          = viewName;
            view.ValueConverterContext = context;

            // set component fields
            foreach (var componentField in viewTypeData.ComponentFields)
            {
                if (viewTypeData.ExcludedComponentFields.Contains(componentField))
                {
                    continue; // exclude component
                }
                var       componentFieldInfo = viewType.GetField(componentField);
                Component component          = null;
                if (componentField == "Transform")
                {
                    component = go.transform;
                }
                else if (componentField == "RectTransform")
                {
                    component = go.transform as RectTransform;
                }
                else
                {
                    component = go.AddComponent(componentFieldInfo.FieldType);
                }
                componentFieldInfo.SetValue(view, component);
            }

            // set view action fields
            foreach (var viewActionField in viewTypeData.ViewActionFields)
            {
                var viewActionFieldInfo = viewTypeData.GetViewField(viewActionField);
                viewActionFieldInfo.SetValue(view, new ViewAction(viewActionField));
            }

            // set dependency fields
            foreach (var dependencyField in viewTypeData.DependencyFields)
            {
                var dependencyFieldInfo     = viewTypeData.GetViewField(dependencyField);
                var dependencyFieldInstance = TypeHelper.CreateViewField(dependencyFieldInfo.FieldType);
                dependencyFieldInfo.SetValue(view, dependencyFieldInstance);
                dependencyFieldInstance.ParentView    = view;
                dependencyFieldInstance.ViewFieldPath = dependencyField;
                dependencyFieldInstance.IsMapped      = !String.Equals(viewTypeData.GetMappedViewField(dependencyField), dependencyField);
            }

            // parse child XUML and for each child create views and set their values
            foreach (var childElement in viewTypeData.XumlElement.Elements())
            {
                var childViewIdAttr    = childElement.Attribute("Id");
                var childViewStyleAttr = childElement.Attribute("Style");
                var childThemeAttr     = childElement.Attribute("Theme");
                var childContext       = GetValueConverterContext(context, childElement, view.GameObjectName);

                var childView = CreateView(childElement.Name.LocalName, view, view, childContext,
                                           childThemeAttr != null ? childThemeAttr.Value : theme,
                                           childViewIdAttr != null ? childViewIdAttr.Value : String.Empty,
                                           GetChildViewStyle(view.Style, childViewStyleAttr),
                                           childElement.Elements());
                SetViewValues(childView, childElement, view, childContext);
            }

            // search for a content placeholder
            ContentPlaceholder contentContainer = view.Find <ContentPlaceholder>(true, view);
            var contentLayoutParent             = view;

            if (contentContainer != null)
            {
                contentLayoutParent = contentContainer.LayoutParent;
                view.Content        = contentLayoutParent;

                // remove placeholder
                GameObject.DestroyImmediate(contentContainer.gameObject);
            }

            // parse content XUML and for each content child create views and set their values
            if (contentXuml != null)
            {
                // create content views
                foreach (var contentElement in contentXuml)
                {
                    var contentElementIdAttr    = contentElement.Attribute("Id");
                    var contentElementStyleAttr = contentElement.Attribute("Style");
                    var contentThemeAttr        = contentElement.Attribute("Theme");
                    var contentContext          = GetValueConverterContext(context, contentElement, view.GameObjectName);

                    var contentView = CreateView(contentElement.Name.LocalName, contentLayoutParent, parent, contentContext,
                                                 contentThemeAttr != null ? contentThemeAttr.Value : theme,
                                                 contentElementIdAttr != null ? contentElementIdAttr.Value : String.Empty,
                                                 GetChildViewStyle(view.Style, contentElementStyleAttr),
                                                 contentElement.Elements());
                    SetViewValues(contentView, contentElement, parent, contentContext);
                }
            }

            // set view references
            foreach (var referenceField in viewTypeData.ReferenceFields)
            {
                // is this a reference to a view?
                var referencedView = view.Find <View>(x => String.Equals(x.Id, referenceField, StringComparison.OrdinalIgnoreCase),
                                                      true, view);
                if (referencedView != null)
                {
                    var referenceFieldInfo = viewType.GetField(referenceField);
                    referenceFieldInfo.SetValue(view, referencedView);
                }
            }

            // set view default values
            view.SetDefaultValues();

            // set internal view values that appear inside the root element of the XUML file
            SetViewValues(view, viewTypeData.XumlElement, view, context);

            // set theme values
            var themeData = GetThemeData(theme);

            if (themeData != null)
            {
                foreach (var themeElement in themeData.GetThemeElementData(view.ViewTypeName, view.Id, view.Style))
                {
                    var themeValueContext = new ValueConverterContext(context);
                    if (themeData.BaseDirectorySet)
                    {
                        themeValueContext.BaseDirectory = themeData.BaseDirectory;
                    }
                    if (themeData.UnitSizeSet)
                    {
                        themeValueContext.UnitSize = themeData.UnitSize;
                    }

                    SetViewValues(view, themeElement.XumlElement, view, themeValueContext);
                }
            }

            return(view);
        }
コード例 #10
0
        internal static ContentPlaceholderHistory Create(IDataStore dataStore, IApplicationSettings applicationSettings, IApplication application, ContentPlaceholder contentPlaceholder, Random random)
        {
            ContentPlaceholderHistoryManager manager = new ContentPlaceholderHistoryManager(dataStore);

            ContentPlaceholderHistory contentPlaceholderHistory = new ContentPlaceholderHistory(
                contentPlaceholder);

            BusinessObjectActionReport <DataRepositoryActionStatus> report = manager.Create(contentPlaceholderHistory);

            Assert.AreEqual(DataRepositoryActionStatus.Success, report.Status);
            Assert.Greater(contentPlaceholderHistory.ContentPlaceholderHistoryId, 0);

            ContentPlaceholderHistory dsThread = manager.GetContentPlaceholderHistory(contentPlaceholderHistory.ContentPlaceholderHistoryId);

            Assert.IsNotNull(dsThread);

            return(dsThread);
        }
コード例 #11
0
     internal Row(
 ContentPlaceholder container,
 double y
 )
     {
         this.Container = container;
         this.Y = y;
     }
コード例 #12
0
        public void ContentPlaceholderClass()
        {
            var x = new ContentPlaceholder("test");

            Assert.Equal("test", x.ElementId);
        }