Exemple #1
0
		/// <summary>
		/// Adds or updates an existing <c>System.Reflection.AssemblySignatureKeyAttribute</c>
		/// attribute. This attribute is used in enhanced strong naming with key migration.
		/// See http://msdn.microsoft.com/en-us/library/hh415055.aspx
		/// </summary>
		/// <param name="identityPubKey">Identity public key</param>
		/// <param name="identityKey">Identity strong name key pair</param>
		/// <param name="signaturePubKey">Signature public key</param>
		public void UpdateOrCreateAssemblySignatureKeyAttribute(StrongNamePublicKey identityPubKey, StrongNameKey identityKey, StrongNamePublicKey signaturePubKey) {
			var manifestModule = ManifestModule;
			if (manifestModule == null)
				return;

			// Remove all existing attributes
			var ca = CustomAttributes.ExecuteLocked<CustomAttribute, object, CustomAttribute>(null, (tsList, arg) => {
				CustomAttribute foundCa = null;
				for (int i = 0; i < tsList.Count_NoLock(); i++) {
					var caTmp = tsList.Get_NoLock(i);
					if (caTmp.TypeFullName != "System.Reflection.AssemblySignatureKeyAttribute")
						continue;
					tsList.RemoveAt_NoLock(i);
					i--;
					if (foundCa == null)
						foundCa = caTmp;
				}
				return foundCa;
			});

			if (IsValidAssemblySignatureKeyAttribute(ca))
				ca.NamedArguments.Clear();
			else
				ca = CreateAssemblySignatureKeyAttribute();

			var counterSig = StrongNameKey.CreateCounterSignatureAsString(identityPubKey, identityKey, signaturePubKey);
			ca.ConstructorArguments[0] = new CAArgument(manifestModule.CorLibTypes.String, new UTF8String(signaturePubKey.ToString()));
			ca.ConstructorArguments[1] = new CAArgument(manifestModule.CorLibTypes.String, new UTF8String(counterSig));
			CustomAttributes.Add(ca);
		}
        public override MobileBlock GetMobile(string parameter)
        {
            var pageList = new List <string>();
            var pages    = GetAttributeValue("PagesToPreload").ToKeyValuePairList();

            foreach (var item in pages)
            {
                var page = "/api/avalanche/page/" +
                           item.Key + "/" +
                           AvalancheUtilities.ProcessLava(( string )item.Value,
                                                          CurrentPerson,
                                                          parameter,
                                                          GetAttributeValue("EnabledLavaCommands")
                                                          );
                pageList.Add(page);
            }

            CustomAttributes.Add("Resources", string.Join("|", pageList));

            return(new MobileBlock()
            {
                BlockType = "Avalanche.Blocks.Preload",
                Attributes = CustomAttributes
            });
        }
        public override MobileBlock GetMobile(string parameter)
        {
            CustomAttributes.Add("Source", AvalancheUtilities.ProcessLava(GetAttributeValue("Source"),
                                                                          CurrentPerson,
                                                                          parameter,
                                                                          GetAttributeValue("EnabledLavaCommands")
                                                                          ));

            CustomAttributes.Add("Artist", AvalancheUtilities.ProcessLava(GetAttributeValue("Artist"),
                                                                          CurrentPerson,
                                                                          parameter,
                                                                          GetAttributeValue("EnabledLavaCommands")
                                                                          ));

            CustomAttributes.Add("Title", AvalancheUtilities.ProcessLava(GetAttributeValue("Title"),
                                                                         CurrentPerson,
                                                                         parameter,
                                                                         GetAttributeValue("EnabledLavaCommands")
                                                                         ));

            CustomAttributes.Add("AutoPlay", GetAttributeValue("AutoPlay"));
            return(new MobileBlock()
            {
                BlockType = "Avalanche.Blocks.AudioPlayerBlock",
                Attributes = CustomAttributes
            });
        }
Exemple #4
0
        public override MobileBlock GetMobile(string parameter)
        {
            GetGroupMembers(parameter);

            if (groupMembers == null)
            {
                return(new MobileBlock()
                {
                    BlockType = "Avalanche.Blocks.LabelBlock",
                    Attributes = new Dictionary <string, string>
                    {
                        { "Text", "Sorry, you are not authorized to update the attendance for the selected group." },
                        { "BackgroundColor", "#f8d7da" },
                        { "TextColor", "#941c24" },
                        { "Margin", "5,10" }
                    }
                });
            }

            List <FormElementItem> elements = GetForm();

            CustomAttributes.Add("FormElementItems", JsonConvert.SerializeObject(elements));

            return(new MobileBlock()
            {
                BlockType = "Avalanche.Blocks.FormBlock",
                Attributes = CustomAttributes
            });
        }
Exemple #5
0
        public override MobileBlock GetMobile(string parameter)
        {
            AvalancheUtilities.SetActionItems(GetAttributeValue("ActionItem"),
                                              CustomAttributes,
                                              CurrentPerson, AvalancheUtilities.GetMergeFields(CurrentPerson),
                                              GetAttributeValue("EnabledLavaCommands"),
                                              parameter);

            if (!string.IsNullOrWhiteSpace(GetAttributeValue("Text")))
            {
                CustomAttributes["Text"] = GetAttributeValue("Text");
            }

            if (GetAttributeValue("AspectRatio").AsDouble() != 0)
            {
                CustomAttributes["AspectRatio"] = GetAttributeValue("AspectRatio");
            }


            CustomAttributes.Add("Source", AvalancheUtilities.ProcessLava(GetAttributeValue("Image"),
                                                                          CurrentPerson,
                                                                          parameter,
                                                                          GetAttributeValue("EnabledLavaCommands")
                                                                          ));
            return(new MobileBlock()
            {
                BlockType = "Avalanche.Blocks.TextOverImage",
                Attributes = CustomAttributes
            });
        }
        private CodeTypeContainer(CodeTypeDeclaration typeDeclaration)
        {
            This            = typeDeclaration;
            Reference       = new CodeTypeReference();
            RequiredImports = new List <CodeNamespaceImport>();
            Name            = typeDeclaration.Name;

            CustomAttributes.Add(GeneratedCodeAttribute);
            RequiredImports.Add("System.CodeDom.Compiler");
        }
Exemple #7
0
 public void AddCustomAttributes(ICustomAttributeProvider provider, IEnumerable <CustomAttribute> customAttributes)
 {
     if (!CustomAttributes.TryGetValue(provider, out var existing))
     {
         CustomAttributes.Add(provider, customAttributes);
     }
     else
     {
         CustomAttributes[provider] = existing.Concat(customAttributes);
     }
 }
        public override MobileBlock GetMobile(string parameter)
        {
            AvalancheUtilities.SetActionItems(GetAttributeValue("ActionItem"), CustomAttributes, CurrentPerson);

            CustomAttributes.Add("Text", AvalancheUtilities.ProcessLava(GetAttributeValue("Text"), CurrentPerson, parameter));
            CustomAttributes.Add("Icon", AvalancheUtilities.ProcessLava(GetAttributeValue("Icon"), CurrentPerson, parameter));

            return(new MobileBlock()
            {
                BlockType = "Avalanche.Blocks.IconButton",
                Attributes = CustomAttributes
            });
        }
Exemple #9
0
        public override MobileBlock GetMobile(string parameter)
        {
            if (CurrentPerson == null)
            {
                return(new MobileBlock()
                {
                    BlockType = "Avalanche.Blocks.Null",
                    Attributes = CustomAttributes
                });
            }
            Person person = null;

            if (parameter == "0")
            {
                person = new Person();
            }
            else
            {
                RockContext        rockContext        = new RockContext();
                PersonAliasService personAliasService = new PersonAliasService(rockContext);
                var personAlias = personAliasService.Get(parameter.AsGuid());
                if (personAlias == null)
                {
                    return(new MobileBlock()
                    {
                        BlockType = "Avalanche.Blocks.Null",
                        Attributes = CustomAttributes
                    });
                }
                person = personAlias.Person;
            }
            if (person.Id != 0 && !CanEdit(person))
            {
                return(new MobileBlock()
                {
                    BlockType = "Avalanche.Blocks.Null",
                    Attributes = CustomAttributes
                });
            }


            var form = GetForm(person, parameter);

            CustomAttributes.Add("FormElementItems", JsonConvert.SerializeObject(form));

            return(new MobileBlock()
            {
                BlockType = "Avalanche.Blocks.FormBlock",
                Attributes = CustomAttributes
            });
        }
        public override MobileBlock GetMobile(string parameter)
        {
            AvalancheUtilities.SetActionItems(GetAttributeValue("ActionItem"), CustomAttributes, CurrentPerson);

            CustomAttributes.Add("Source", AvalancheUtilities.ProcessLava(GetAttributeValue("Image"),
                                                                          CurrentPerson,
                                                                          parameter,
                                                                          GetAttributeValue("EnabledLavaCommands")
                                                                          ));
            CustomAttributes.Add("Aspect", GetAttributeValue("Aspect"));

            return(new MobileBlock()
            {
                BlockType = "Avalanche.Blocks.ImageBlock",
                Attributes = CustomAttributes
            });
        }
Exemple #11
0
        public static CustomAttributes GetCustomAttributes(TaskList tasks)
        {
            var attribs = new CustomAttributes();

            if (tasks.HasCustomAttributes())
            {
                var numAttrib = tasks.GetCustomAttributeCount();

                for (var attrib = 0; attrib < numAttrib; attrib++)
                {
                    attribs.Add(tasks.GetCustomAttributeID(attrib).ToLower(),
                                tasks.GetCustomAttributeLabel(attrib));
                }
            }

            return(attribs);
        }
Exemple #12
0
        public override MobileBlock GetMobile(string parameter)
        {
            CustomAttributes.Add("Text", AvalancheUtilities.ProcessLava(GetAttributeValue("Text"),
                                                                        CurrentPerson,
                                                                        parameter,
                                                                        GetAttributeValue("EnabledLavaCommands")));

            AvalancheUtilities.SetActionItems(GetAttributeValue("ActionItem"),
                                              CustomAttributes,
                                              CurrentPerson, AvalancheUtilities.GetMergeFields(CurrentPerson),
                                              GetAttributeValue("EnabledLavaCommands"),
                                              parameter);


            return(new MobileBlock()
            {
                BlockType = "Avalanche.Blocks.ButtonBlock",
                Attributes = CustomAttributes
            });
        }
Exemple #13
0
        public override MobileBlock GetMobile(string parameter)
        {
            HttpContext.Current.Response.AddHeader("ActionType", "1");
            var h = HttpContext.Current.Response.Headers;
            var b = h.GetValues("ActionTypes");

            if (HydrateObjects())
            {
                List <FormElementItem> elements = BuildForm(true);
                CustomAttributes.Add("FormElementItems", JsonConvert.SerializeObject(elements));
                ProcessActionRequest(parameter);
                return(new MobileBlock()
                {
                    BlockType = "Avalanche.Blocks.FormBlock",
                    Attributes = CustomAttributes
                });
            }

            return(new MobileBlock());
        }
Exemple #14
0
        /// <summary>
        /// Adds or updates an existing <c>System.Reflection.AssemblySignatureKeyAttribute</c>
        /// attribute. This attribute is used in enhanced strong naming with key migration.
        /// See http://msdn.microsoft.com/en-us/library/hh415055.aspx
        /// </summary>
        /// <param name="identityPubKey">Identity public key</param>
        /// <param name="identityKey">Identity strong name key pair</param>
        /// <param name="signaturePubKey">Signature public key</param>
        public void UpdateOrCreateAssemblySignatureKeyAttribute(StrongNamePublicKey identityPubKey, StrongNameKey identityKey, StrongNamePublicKey signaturePubKey)
        {
            if (ManifestModule == null)
            {
                return;
            }

            // Remove all existing attributes
            CustomAttribute ca = null;

            for (int i = 0; i < CustomAttributes.Count; i++)
            {
                var caTmp = CustomAttributes[i];
                if (caTmp.TypeFullName != "System.Reflection.AssemblySignatureKeyAttribute")
                {
                    continue;
                }
                CustomAttributes.RemoveAt(i);
                i--;
                if (ca == null)
                {
                    ca = caTmp;
                }
            }

            if (IsValidAssemblySignatureKeyAttribute(ca))
            {
                ca.NamedArguments.Clear();
            }
            else
            {
                ca = CreateAssemblySignatureKeyAttribute();
            }

            var counterSig = StrongNameKey.CreateCounterSignatureAsString(identityPubKey, identityKey, signaturePubKey);

            ca.ConstructorArguments[0] = new CAArgument(ManifestModule.CorLibTypes.String, new UTF8String(signaturePubKey.ToString()));
            ca.ConstructorArguments[1] = new CAArgument(ManifestModule.CorLibTypes.String, new UTF8String(counterSig));
            CustomAttributes.Add(ca);
        }
        public override MobileBlock GetMobile(string parameter)
        {
            var noteTypeString = GetAttributeValue("NoteType");
            var noteType       = NoteTypeCache.Read(noteTypeString.AsGuid());

            if (CurrentPerson == null || noteType == null)
            {
                return(new MobileBlock()
                {
                    BlockType = "Avalanche.Blocks.Null",
                    Attributes = CustomAttributes
                });
            }

            var form = GetForm(noteType, parameter.AsInteger());

            CustomAttributes.Add("FormElementItems", JsonConvert.SerializeObject(form));

            return(new MobileBlock()
            {
                BlockType = "Avalanche.Blocks.FormBlock",
                Attributes = CustomAttributes
            });
        }
Exemple #16
0
        public override MobileBlock GetMobile(string parameter)
        {
            var form = new List <FormElementItem>();

            var firstName = new FormElementItem
            {
                Type     = FormElementType.Entry,
                Key      = "firstName",
                Label    = "First Name",
                Required = true
            };

            if (CurrentPerson != null)
            {
                firstName.Value = CurrentPerson.NickName;
            }
            form.Add(firstName);

            var lastName = new FormElementItem
            {
                Type     = FormElementType.Entry,
                Key      = "lastName",
                Label    = "Last Name",
                Required = GetAttributeValue("RequireLastName").AsBoolean()
            };

            if (CurrentPerson != null)
            {
                lastName.Value = CurrentPerson.LastName;
            }
            form.Add(lastName);

            var email = new FormElementItem
            {
                Type     = FormElementType.Entry,
                Key      = "email",
                Label    = "Email",
                Required = false,
                Keyboard = Keyboard.Email
            };

            if (CurrentPerson != null)
            {
                email.Value = CurrentPerson.Email;
            }
            form.Add(email);

            if (GetAttributeValue("ShowCampus").AsBoolean())
            {
                var campus = new FormElementItem
                {
                    Type     = FormElementType.Picker,
                    Key      = "campus",
                    Label    = "Campus",
                    Options  = CampusCache.All().ToDictionary(c => c.Id.ToString(), c => c.Name),
                    Required = GetAttributeValue("RequireCampus").AsBoolean()
                };
                if (CurrentPerson != null)
                {
                    campus.Value = CurrentPerson.GetCampus().Id.ToString();
                }

                form.Add(campus);
            }

            if (!string.IsNullOrWhiteSpace(GetAttributeValue("CategorySelection")))
            {
                var categoryGuid = GetAttributeValue("CategorySelection").AsGuid();
                var categoryList = CategoryCache.Read(categoryGuid).Categories.ToDictionary(c => c.Id.ToString(), c => c.Name);

                var category = new FormElementItem
                {
                    Type     = FormElementType.Picker,
                    Key      = "category",
                    Label    = "Category",
                    Options  = categoryList,
                    Required = true
                };
                form.Add(category);
            }

            var request = new FormElementItem
            {
                Type          = FormElementType.Editor,
                Label         = "Request",
                Key           = "request",
                HeightRequest = 100,
                Required      = true
            };

            form.Add(request);

            if (GetAttributeValue("EnableUrgentFlag").AsBoolean())
            {
                var urgent = new FormElementItem
                {
                    Type  = FormElementType.Switch,
                    Key   = "urgent",
                    Label = "Urgent?"
                };
                form.Add(urgent);
            }

            if (GetAttributeValue("DefaultAllowCommentsSetting").AsBoolean())
            {
                var allowComments = new FormElementItem
                {
                    Type  = FormElementType.Switch,
                    Key   = "allowComments",
                    Label = "Allow Encouraging Comments?"
                };
                form.Add(allowComments);
            }

            if (GetAttributeValue("EnablePublicDisplayFlag").AsBoolean())
            {
                var allowPublication = new FormElementItem
                {
                    Type  = FormElementType.Switch,
                    Key   = "allowPublication",
                    Label = "Allow Publication?"
                };
                form.Add(allowPublication);
            }

            var button = new FormElementItem
            {
                Type  = FormElementType.Button,
                Label = "Save Request",
                Key   = "save"
            };

            form.Add(button);

            CustomAttributes.Add("FormElementItems", JsonConvert.SerializeObject(form));
            return(new MobileBlock()
            {
                BlockType = "Avalanche.Blocks.FormBlock",
                Attributes = CustomAttributes
            });
        }