Пример #1
0
 /// <summary>
 /// Backs the view reference.
 /// </summary>
 /// <returns>
 /// The <see cref="ViewReference"/>.
 /// </returns>
 public static ViewReference BackViewReference()
 {
     return(backViewReference
            ?? (backViewReference = new ViewReference(new Dictionary <string, object> {
         { "back", "Action" }
     }, "OrganizerAction")));
 }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ViewReference"/> class.
        /// </summary>
        /// <param name="viewReference">
        /// The view reference.
        /// </param>
        /// <param name="oldValue">
        /// The old value.
        /// </param>
        /// <param name="newValue">
        /// The new value.
        /// </param>
        /// <param name="searchKey">
        /// The search key.
        /// </param>
        public ViewReference(ViewReference viewReference, string oldValue, string newValue, string searchKey)
        {
            this.ViewName  = viewReference.ViewName;
            this.Name      = viewReference.Name;
            this.Arguments = new Dictionary <string, ReferenceArgument>();
            var replaceByValue = string.IsNullOrWhiteSpace(searchKey);
            var found          = false;

            foreach (var key in viewReference.Arguments.Keys)
            {
                var arg = viewReference.Arguments[key];
                if (replaceByValue && arg.Value == oldValue)
                {
                    this.Arguments[key] = new ReferenceArgument(key, newValue);
                }
                else if (!replaceByValue && arg.Name == searchKey)
                {
                    this.Arguments[key] = new ReferenceArgument(searchKey, newValue);
                    found = true;
                }
                else
                {
                    this.Arguments[key] = arg;
                }
            }

            if (!found && !string.IsNullOrWhiteSpace(searchKey))
            {
                this.Arguments[searchKey] = new ReferenceArgument(searchKey, newValue);
            }
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ViewReference"/> class.
        /// </summary>
        /// <param name="viewReference">
        /// The view reference.
        /// </param>
        /// <param name="currentContext">
        /// The current context.
        /// </param>
        /// <param name="addValues">
        /// The add values.
        /// </param>
        /// <param name="yieldAddValues">
        /// if set to <c>true</c> [yield add values].
        /// </param>
        public ViewReference(
            ViewReference viewReference,
            Dictionary <string, string> currentContext,
            Dictionary <string, object> addValues,
            bool yieldAddValues)
        {
            this.ViewName = viewReference.ViewName;
            this.Name     = viewReference.Name;
            if (currentContext != null)
            {
                this.Arguments = new Dictionary <string, ReferenceArgument>();
                if (viewReference.Arguments != null)
                {
                    foreach (var arg in viewReference.Arguments.Values)
                    {
                        var currentContextValue = currentContext.ValueOrDefault(arg.Value);
                        if (currentContextValue != null)
                        {
                            this.Arguments[arg.Name] = new ReferenceArgument(arg, currentContextValue);
                        }
                        else
                        {
                            this.Arguments[arg.Name] = arg;
                        }
                    }
                }
            }
            else
            {
                this.Arguments = new Dictionary <string, ReferenceArgument>(viewReference.Arguments);
            }

            if (addValues != null)
            {
                foreach (string key in addValues.Keys)
                {
                    ReferenceArgument arg = this.Arguments.ValueOrDefault(key);
                    if (!yieldAddValues || string.IsNullOrWhiteSpace(arg?.Value))
                    {
                        this.Arguments[key] = new ReferenceArgument(key, addValues[key] as string);
                    }
                }
            }
        }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ViewReference"/> class.
 /// </summary>
 /// <param name="viewReference">
 /// The view reference.
 /// </param>
 /// <param name="valueDictionary">
 /// The value dictionary.
 /// </param>
 /// <param name="nilWithOpenValues">
 /// if set to <c>true</c> [nil with open values].
 /// </param>
 public ViewReference(ViewReference viewReference, Dictionary <string, object> valueDictionary, bool nilWithOpenValues)
 {
     this.ViewName  = viewReference.ViewName;
     this.Name      = viewReference.Name;
     this.Arguments = new Dictionary <string, ReferenceArgument>();
     foreach (var key in viewReference.Arguments.Keys)
     {
         var arg          = viewReference.Arguments.ValueOrDefault(key);
         var replaceValue = valueDictionary.ValueOrDefault(arg.Value) as string;
         if (!string.IsNullOrWhiteSpace(replaceValue))
         {
             this.Arguments[key] = new ReferenceArgument(key, replaceValue);
         }
         else if (nilWithOpenValues && arg.Value.StartsWith("$"))
         {
             return;
         }
         else
         {
             this.Arguments[key] = arg;
         }
     }
 }
Пример #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ViewReference"/> class.
 /// </summary>
 /// <param name="viewReference">
 /// The view reference.
 /// </param>
 /// <param name="currentContext">
 /// The current context.
 /// </param>
 public ViewReference(ViewReference viewReference, Dictionary <string, string> currentContext)
     : this(viewReference, currentContext, null, true)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="UPConfigButton"/> class.
 /// </summary>
 /// <param name="label">
 /// The label.
 /// </param>
 /// <param name="imageName">
 /// Name of the image.
 /// </param>
 /// <param name="viewReference">
 /// The view reference.
 /// </param>
 public UPConfigButton(string label, string imageName, ViewReference viewReference)
 {
     this.Label         = label;
     this.ImageName     = imageName;
     this.ViewReference = viewReference;
 }