public void NullCheckingCanBeDoneOnProperties() {
            var contentItem = new ContentItem();
            var contentPart = new ContentPart { TypePartDefinition = new ContentTypePartDefinition(new ContentPartDefinition("FooPart"), new SettingsDictionary()) };
            var contentField = new ContentField { PartFieldDefinition = new ContentPartFieldDefinition(new ContentFieldDefinition("FooType"), "FooField", new SettingsDictionary()) };

            dynamic item = contentItem;
            dynamic part = contentPart;

            Assert.That(item.FooPart == null, Is.True);
            Assert.That(item.FooPart != null, Is.False);

            contentItem.Weld(contentPart);

            Assert.That(item.FooPart == null, Is.False);
            Assert.That(item.FooPart != null, Is.True);
            Assert.That(item.FooPart, Is.SameAs(contentPart));

            Assert.That(part.FooField == null, Is.True);
            Assert.That(part.FooField != null, Is.False);
            Assert.That(item.FooPart.FooField == null, Is.True);
            Assert.That(item.FooPart.FooField != null, Is.False);

            contentPart.Weld(contentField);

            Assert.That(part.FooField == null, Is.False);
            Assert.That(part.FooField != null, Is.True);
            Assert.That(item.FooPart.FooField == null, Is.False);
            Assert.That(item.FooPart.FooField != null, Is.True);
            Assert.That(part.FooField, Is.SameAs(contentField));
            Assert.That(item.FooPart.FooField, Is.SameAs(contentField));
        }
        public dynamic UpdateEditor(IContent content, ContentField field, IUpdateModel updater, string groupInfoId) {
            var context = UpdateEditorContext(content, updater, groupInfoId);
            var drivers = GetFieldDrivers(field.FieldDefinition.Name);

            drivers.Invoke(driver => {
                var result = driver.UpdateEditorShape(context);
                if (result != null)
                    result.Apply(context);
            }, Logger);
            
            return context.Shape;
        }
        public dynamic BuildEditor(IContent content, ContentField field, string groupId) {
            var context = BuildEditorContext(content, groupId);
            var drivers = GetFieldDrivers(field.FieldDefinition.Name);

            drivers.Invoke(driver => {
                var result = driver.BuildEditorShape(context);
                if (result != null)
                    result.Apply(context);
            }, Logger);

            return context.Shape;
        }
예제 #4
0
        public dynamic BuildDisplay(IContent content, ContentField field, string displayType, string groupId) {
            var context = BuildDisplayContext(content, displayType, groupId);
            var drivers = GetFieldDrivers(field.FieldDefinition.Name);

            drivers.Invoke(driver => {
                var result = Filter(driver.BuildDisplayShape(context), field);
                if (result != null)
                    result.Apply(context);
            }, Logger);

            return context.Shape;
        }
예제 #5
0
        private DriverResult Filter(DriverResult driverResult, ContentField field) {
            DriverResult result = null;
            var combinedResult = driverResult as CombinedResult;
            var contentShapeResult = driverResult as ContentShapeResult;

            if (combinedResult != null) {
                result = combinedResult.GetResults().SingleOrDefault(x => x.ContentField != null && x.ContentField.Name == field.Name);
            }
            else if (contentShapeResult != null) {
                result = contentShapeResult.ContentField != null && contentShapeResult.ContentField.Name == field.Name ? contentShapeResult : driverResult;
            }

            return result;
        }
        protected JObject SerializeField(ContentField field) {
            var fieldObject = new JObject();
            fieldObject.Add(new JProperty("Name", field.Name));
            fieldObject.Add(new JProperty("DisplayName", field.DisplayName));
            fieldObject.Add(new JProperty("Value", field.Storage.Get<string>()));

            // add the part settings...
            var fieldSettingsObject = new JObject();

            foreach (string key in field.PartFieldDefinition.Settings.Keys)
            {
                fieldSettingsObject.Add(new JProperty(key, field.PartFieldDefinition.Settings[key]));
            }

            fieldObject.Add("PartFieldDefinition.Settings", fieldSettingsObject);

            return fieldObject;
        }
예제 #7
0
 public void Weld(ContentField field)
 {
     Fields.Add(field);
 }
예제 #8
0
 public void Weld(ContentField field)
 {
     _fields.Add(field);
 }
예제 #9
0
 private bool CheckValue(ContentField field, string value)
 {
     if (((TextField)field).Value != value)
     {
         ((TextField)field).Value = value;
         return true;
     }
     return false;
 }