private DocumentTypeSynchronizer() { _installedDocumentTypes = DocumentType.GetAllAsList(); _typesWithDocumentTypeAttribute = TypeFinder.FindClassesMarkedWithAttribute(typeof(DocumentTypeAttribute)).ToList(); _documentTypeIdTypeMappings = new Dictionary <int, Type>(); _typeDocumentTypeIdMappings = new Dictionary <Type, int>(); LoadInstalledDocumentTypes(); }
/// <summary> /// Loads the registered resources. /// </summary> private void LoadRegisteredResources() { var config = WebConfigurationManager.OpenWebConfiguration("~/"); var section = config.GetSection(Common.ConfigName) as ConfigSection; var application = Application.Instance; foreach (ScriptElement script in section.Scripts) { application.AddJavaScript(script.Path, script.Targets, 100); } foreach (StyleElement style in section.Styles) { application.AddCss(style.Path, style.Targets, 100); } foreach (var type in TypeFinder.FindClassesMarkedWithAttribute(typeof(ClientResourceAttribute))) { foreach (ClientResourceAttribute attribute in type.GetCustomAttributes(typeof(ClientResourceAttribute), false)) { application.AddClientResource(attribute.ClientResource); } } }
public restExtension(string extensionAlias, string methodName) { bool allowed = false; bool fromFile = true; XmlDocument baseDoc = new XmlDocument(); //RESTExtension document... baseDoc.Load(IOHelper.MapPath(SystemFiles.RestextensionsConfig)); XmlNode baseExt = baseDoc.SelectSingleNode("/RestExtensions/ext [@alias='" + extensionAlias + "']/permission [@method='" + methodName + "']"); //if not there.. it's not allowed... if (baseExt != null) { //Access for all ? if (baseExt.Attributes["allowAll"] != null) { if (baseExt.Attributes["allowAll"].Value.ToString().ToLower() == "true") { allowed = true; } } if (!allowed) { //Member Based permissions.. check for group, type and ID... Member currentMem = Member.GetCurrentMember(); //not basic.. and not logged in? - out.. if (currentMem == null) { allowed = false; } else //do member authentication stuff... { allowed = memberAuthentication(baseExt, currentMem); } } } else { //check for RestExtensionAttribute foreach (Type t in TypeFinder.FindClassesMarkedWithAttribute(typeof(RestExtension))) { var temp = t.GetCustomAttributes(typeof(RestExtension), false).OfType <RestExtension>(); if (temp.Where(x => x.GetAlias() == extensionAlias) .Any()) { MethodInfo mi = t.GetMethod(methodName); if (mi != null) { //check allowed var attributes = mi.GetCustomAttributes(typeof(RestExtensionMethod), false).OfType <RestExtensionMethod>(); //check to make sure the method was decorated properly if (attributes.Any()) { fromFile = false; var attribute = attributes.First(); allowed = attribute.allowAll; if (!allowed) { //Member Based permissions.. check for group, type and ID... Member currentMem = Member.GetCurrentMember(); //not basic.. and not logged in? - out.. if (currentMem == null) { allowed = false; } else { //do member authentication stuff... allowed = memberAuthentication(attribute, currentMem); } } if (allowed) { this.isAllowed = true; this.alias = extensionAlias; this.assembly = t.Assembly; this.method = t.GetMethod(methodName); this.type = t; this.returnXML = attribute.returnXml; } } } } } } if (allowed) { if (fromFile) { XmlNode extNode = baseDoc.SelectSingleNode("/RestExtensions/ext [@alias='" + extensionAlias + "']"); string asml = extNode.Attributes["assembly"].Value; string assemblyPath = IOHelper.MapPath(string.Format("{0}/{1}.dll", SystemDirectories.Bin, asml.TrimStart('/'))); Assembly returnAssembly = System.Reflection.Assembly.LoadFrom(assemblyPath); string returnTypeName = extNode.Attributes["type"].Value; Type returnType = returnAssembly.GetType(returnTypeName); if (baseExt.Attributes["returnXml"] != null && baseExt.Attributes["returnXml"].Value.ToLower() == "false") { this.returnXML = false; } this.isAllowed = true; this.alias = extensionAlias; this.assembly = returnAssembly; this.method = returnType.GetMethod(methodName); this.type = returnType; } } else { this.isAllowed = false; } }