예제 #1
0
 static void CheckDetailViewId(String detailViewId, Type objectType)
 {
     if (String.IsNullOrEmpty(detailViewId))
     {
         throw new Exception(
                   SystemExceptionLocalizer.GetExceptionMessage(ExceptionId.UnableToFindADetailViewForType,
                                                                objectType.FullName));
     }
 }
        protected override void AddColumn(string propertyName)
        {
            IModelColumn columnInfo = FindColumnModelByPropertyName(propertyName);

            if (columnInfo == null)
            {
                columnInfo              = ((ListView)View).Model.Columns.AddNode <IModelColumn>();
                columnInfo.Id           = propertyName;
                columnInfo.PropertyName = propertyName;
                columnInfo.Index        = -1;
                GridEditor.AddColumn(columnInfo);
            }
            else
            {
                throw new Exception(SystemExceptionLocalizer.GetExceptionMessage(
                                        ExceptionId.CannotAddDuplicateProperty, propertyName));
            }
            gridView.CustomizationForm.CheckAndUpdate();
        }
예제 #3
0
        private static string GetDashboardXml(string resourceName)
        {
            string   xml      = null;
            Assembly assembly = Assembly.GetExecutingAssembly();

            using (Stream stream = assembly.GetManifestResourceStream(resourceName)) {
                if (stream != null)
                {
                    using (StreamReader reader = new StreamReader(stream)) {
                        xml = reader.ReadToEnd();
                        xml = xml.Replace("'", "''");
                    }
                }
                else
                {
                    throw new Exception(SystemExceptionLocalizer.GetExceptionMessage(ExceptionId.ResourceItemWithNameIsNotFound, resourceName));
                }
            }
            return(xml);
        }
 /// <summary>
 /// Layouts the controls.
 /// </summary>
 /// <param name="layoutInfo">The layout information.</param>
 /// <param name="repositoryControls">The repository controls.</param>
 /// <returns></returns>
 /// <exception cref="ArgumentException">
 /// The layoutInfo isn't IModelSplitLayout
 /// or
 /// repositoryControls
 /// </exception>
 public override object LayoutControls(IModelNode layoutInfo, ViewItemsCollection repositoryControls)
 {
     if (!(layoutInfo is IModelSplitLayout))
     {
         throw new ArgumentException("The layoutInfo isn't IModelSplitLayout");
     }
     if (repositoryControls.Count == 2)
     {
         LayoutControls((IModelSplitLayout)layoutInfo, repositoryControls[0], repositoryControls[1]);
     }
     else if (repositoryControls.Count == 1)
     {
         LayoutControls((IModelSplitLayout)layoutInfo, repositoryControls[0], null);
     }
     else
     {
         throw new ArgumentException(SystemExceptionLocalizer.GetExceptionMessage(ExceptionId.LayoutControlInvalidCount, repositoryControls.Count), "repositoryControls");
     }
     return(Container);
 }
예제 #5
0
        //TODO: Implement adding new properties into the customization form.
        protected override void AddColumn(string propertyName)
        {
            IModelColumn columnInfo = FindColumnModelByPropertyName(propertyName);

            if (columnInfo == null)
            {
                columnInfo              = ListEditor.Model.Columns.AddNode <IModelColumn>();
                columnInfo.Id           = propertyName;
                columnInfo.PropertyName = propertyName;
                columnInfo.Index        = -1;
                var wrapper = ListEditor.AddColumn(columnInfo) as XafGridColumnWrapper;
                if (wrapper != null && wrapper.Column is LayoutViewColumn && ((LayoutViewColumn)wrapper.Column).LayoutViewField != null)
                {
                    ((ListBoxControl)ActiveListBox).Items.Add(((LayoutViewColumn)wrapper.Column).LayoutViewField);
                }
            }
            else
            {
                throw new Exception(SystemExceptionLocalizer.GetExceptionMessage(ExceptionId.CannotAddDuplicateProperty, propertyName));
            }
        }
예제 #6
0
        public static XpandListView CreateListView(XafApplication xafApplication, string viewId, CollectionSourceBase collectionSource,
                                                   bool isRoot)
        {
            IModelView modelView = xafApplication.FindModelView(viewId);

            if (modelView == null)
            {
                throw new Exception(SystemExceptionLocalizer.GetExceptionMessage(ExceptionId.NodeWasNotFound, viewId));
            }
            var modelListView = ((IModelListView)modelView);

            if (modelListView == null)
            {
                throw new ArgumentException(
                          $"A '{typeof(IModelDetailView).Name}' node was passed while a '{typeof(IModelListView).Name}' node was expected. Node id: '{modelListView.Id}'");
            }
            var result = new XpandListView(collectionSource, xafApplication, isRoot);

            result.SetModel(modelListView);
            return(result);
        }
예제 #7
0
 public static string Format(string format, object obj, EmptyEntriesMode mode)
 {
     if (string.IsNullOrEmpty(format))
     {
         return(string.Empty);
     }
     try
     {
         format = format.Replace("{{", uniqStrOBrace).Replace("}}", uniqStrEBrace);
         char[]        chArray      = format.ToCharArray(0, format.Length);
         int           length       = chArray.Length;
         StringBuilder pieceBuilder = new StringBuilder();
         List <string> pieces       = new List <string>();
         bool          isBrStart    = false;
         for (int i = 0; i < length; i++)
         {
             char ch = chArray[i];
             if (ch == '{')
             {
                 if (isBrStart)
                 {
                     throw new FormatException(SystemExceptionLocalizer.GetExceptionMessage(ExceptionId.ObjectFormatterFormatStringIsInvalid, format));
                 }
                 isBrStart = true;
                 if (pieceBuilder.Length > 0)
                 {
                     pieces.Add(pieceBuilder.ToString());
                 }
                 pieceBuilder = new StringBuilder();
                 pieceBuilder.Append(ch);
             }
             else if (ch == '}')
             {
                 if (!isBrStart)
                 {
                     throw new FormatException(SystemExceptionLocalizer.GetExceptionMessage(ExceptionId.ObjectFormatterFormatStringIsInvalid, format));
                 }
                 if (pieceBuilder.Length <= 1)
                 {
                     throw new FormatException(SystemExceptionLocalizer.GetExceptionMessage(ExceptionId.ObjectFormatterFormatStringIsInvalid, format));
                 }
                 isBrStart = false;
                 pieceBuilder.Append(ch);
                 pieces.Add(pieceBuilder.ToString());
                 pieceBuilder = new StringBuilder();
             }
             else
             {
                 pieceBuilder.Append(ch);
             }
         }
         if (pieceBuilder.Length > 0)
         {
             pieces.Add(pieceBuilder.ToString());
         }
         if (isBrStart)
         {
             throw new FormatException(SystemExceptionLocalizer.GetExceptionMessage(ExceptionId.ObjectFormatterFormatStringIsInvalid, format));
         }
         StringBuilder result                    = new StringBuilder();
         string        lastDelimiter             = null;
         bool          isLastFormattedpieceEmpty = false;
         bool          hasNonEmptyFormattedpiece = false;
         for (int i = 0; i < pieces.Count; i++)
         {
             if (pieces[i].StartsWith("{"))
             {
                 string piece = pieces[i];
                 if (!piece.StartsWith("{0:"))
                 {
                     piece = "{0:" + piece.Substring(1, piece.Length - 1);
                 }
                 string formattedpiece = string.Format(new ObjectFormatter(), piece, obj);
                 if (!string.IsNullOrEmpty(formattedpiece))
                 {
                     if (!string.IsNullOrEmpty(lastDelimiter) &&
                         ((mode == EmptyEntriesMode.Default) || hasNonEmptyFormattedpiece || !isLastFormattedpieceEmpty))
                     {
                         result.Append(lastDelimiter);
                     }
                     hasNonEmptyFormattedpiece = true;
                     result.Append(formattedpiece);
                 }
                 else
                 {
                     isLastFormattedpieceEmpty = true;
                     if (!string.IsNullOrEmpty(lastDelimiter) && (mode == EmptyEntriesMode.Default))
                     {
                         result.Append(lastDelimiter);
                     }
                 }
                 lastDelimiter = null;
             }
             else
             {
                 lastDelimiter = pieces[i];
             }
         }
         if (!string.IsNullOrEmpty(lastDelimiter) && ((mode == EmptyEntriesMode.Default) || !isLastFormattedpieceEmpty))
         {
             result.Append(lastDelimiter);
         }
         return(result.ToString().Replace(uniqStrOBrace, "{").Replace(uniqStrEBrace, "}"));
     }
     catch (Exception e)
     {
         Tracing.Tracer.LogValue("format", format);
         if (e is FormatException)
         {
             Tracing.Tracer.LogValue("obj", e.Message);
         }
         Tracing.Tracer.LogValue("mode", mode);
         throw;
     }
 }