public void DeliverCustomToolbarDefinition(Guid instanceId, string customToolbarDefinition) { Verify.ArgumentNotNullOrEmpty(customToolbarDefinition, nameof(customToolbarDefinition)); AddCustomToolbarItem(instanceId, "default", XDocument.Parse(customToolbarDefinition), ActionGroupPriority.TargetedAppendMedium); }
/// <summary> /// Will indicate that the search results should return facet information for the given field. /// </summary> /// <param name="fieldName"></param> public void AddFieldFacet(string fieldName) { Verify.ArgumentNotNullOrEmpty(fieldName, nameof(fieldName)); if (Facets.Any(f => f.Key == fieldName)) { return; } var field = SearchDocumentBuilder.GetDefaultDocumentFields() .FirstOrDefault(f => f.Name == fieldName); if (field == null) { field = SearchFacade.DocumentSources.SelectMany(f => f.CustomFields) .FirstOrDefault(f => f.Name == fieldName); Verify.IsNotNull(field, $"Failed to find a document field by name '{fieldName}'"); } Verify.IsNotNull(field.Facet, $"Faceted search is not enabled for the field '{fieldName}'"); Facets.Add(new KeyValuePair <string, DocumentFieldFacet>( fieldName, field.Facet)); }
public static string Decrypt(string encryptedValue) { Verify.ArgumentNotNullOrEmpty(encryptedValue, nameof(encryptedValue)); byte[] encodedSequence = HexStringToByteArray(encryptedValue); return(RijndaelDecrypt(encodedSequence)); }
public List <ClientValidationRule> GetClientValidationRules(Type type, string propertyName) { Verify.ArgumentNotNull(type, "type"); Verify.ArgumentNotNullOrEmpty(propertyName, "propertyName"); PropertyInfo propertyInfo = type.GetProperty(propertyName); Verify.IsNotNull(propertyInfo, "The property named '{0}' not found on the type '{1}'", propertyName, type); List <ValidatorAttribute> attributes = propertyInfo.GetCustomAttributesRecursively <ValidatorAttribute>().ToList(); var rules = new List <ClientValidationRule>(); foreach (ValidatorAttribute attribute in attributes) { string translatorName = ClientValidationRuleTranslatorRegistry.GetTranslatorName(attribute.GetType()); if (translatorName != null) { ClientValidationRule rule = ClientValidationRuleTranslatorPluginFacade.Translate(translatorName, attribute); rules.Add(rule); } } return(rules); }
public void GenerateNewTypes(string providerName, IReadOnlyCollection <DataTypeDescriptor> dataTypeDescriptors, bool makeAFlush) { Verify.ArgumentNotNullOrEmpty(providerName, "providerName"); Verify.ArgumentNotNull(dataTypeDescriptors, "dataTypeDescriptors"); foreach (var dataTypeDescriptor in dataTypeDescriptors) { UpdateWithNewMetaDataForeignKeySystem(dataTypeDescriptor); UpdateWithNewPageFolderForeignKeySystem(dataTypeDescriptor, false); } var types = DataTypeTypesManager.GetDataTypes(dataTypeDescriptors); foreach (var dataTypeDescriptor in dataTypeDescriptors) { dataTypeDescriptor.TypeManagerTypeName = TypeManager.SerializeType(types[dataTypeDescriptor.DataTypeId]); } DynamicTypeManager.CreateStores(providerName, dataTypeDescriptors, makeAFlush); if (makeAFlush && dataTypeDescriptors.Any(d => d.IsCodeGenerated)) { CodeGenerationManager.GenerateCompositeGeneratedAssembly(true); } }
/// <exclude /> public static IEnumerable <UserPermissionDefinition> GetUserPermissionDefinitions(string username) { Verify.ArgumentNotNullOrEmpty(username, "username"); IEnumerable <UserPermissionDefinition> userPermissionDefinitions = UserPermissionDefinitionProviderPluginFacade.GetPermissionsByUser(username); var result = new List <UserPermissionDefinition>(); foreach (UserPermissionDefinition userPermissionDefinition in userPermissionDefinitions) { EntityToken entityToken = userPermissionDefinition.EntityToken; if (entityToken == null) { continue; } if (!entityToken.IsValid()) { if (UserPermissionDefinitionProviderPluginFacade.CanAlterDefinitions) { Log.LogWarning("PermissionTypeFacade", "System removing invalid permission setting for user '{0}' because the data entity token could not be validated. Token was '{1}'.", username, userPermissionDefinition.SerializedEntityToken); UserPermissionDefinitionProviderPluginFacade.RemoveUserPermissionDefinition(new UserToken(username), userPermissionDefinition.SerializedEntityToken); } continue; } result.Add(userPermissionDefinition); } return(result); }
/// <summary> /// Use this method to register data type descriptors that have been validated and will be /// intstalled. /// </summary> /// <param name="interfaceName"></param> /// <param name="dataTypeDescriptor"></param> public void AddPendingDataTypeDescritpor(string interfaceName, DataTypeDescriptor dataTypeDescriptor) { Verify.ArgumentNotNullOrEmpty(interfaceName, "interfaceName"); Verify.ArgumentNotNull(dataTypeDescriptor, "dataTypeDescriptor"); _pendingDataTypeDescriptors.Add(interfaceName, dataTypeDescriptor); }
public static IEnumerable <XElement> GetElements(string filePath, string elementName, IXmlDataProviderHelper helper) { Verify.ArgumentNotNullOrEmpty(filePath, "filename"); Verify.ArgumentNotNullOrEmpty(elementName, "elementName"); return(GetFileRecord(filePath, elementName, helper.CreateDataId).ReadOnlyElementsList); }
/// <exclude /> public static IData GetReferenced(this IData refereeData, string foreignKeyPropertyName) { Verify.ArgumentNotNull(refereeData, "refereeData"); Verify.ArgumentNotNullOrEmpty(foreignKeyPropertyName, "foreignKeyPropertyName"); ForeignPropertyInfo foreignPropertyInfo = (from fkpi in DataReferenceRegistry.GetForeignKeyProperties(refereeData.DataSourceId.InterfaceType) where fkpi.SourcePropertyName == foreignKeyPropertyName select fkpi).Single(); object sourceKeyValue = foreignPropertyInfo.SourcePropertyInfo.GetValue(refereeData, null); // Handling of Nullable<> if (sourceKeyValue == null) { return(null); } Type targetType = foreignPropertyInfo.TargetType; var dataset = DataFacade.GetData(targetType); IEnumerable queryResult = GetReferences(dataset, targetType, foreignPropertyInfo.TargetKeyPropertyInfo, sourceKeyValue, true); foreach (var result in queryResult) { Verify.That(result is IData, "Query result should implement '{0}' interface", typeof(IData).FullName); return(result as IData); } return(null); }
/// <exclude /> public static void AddZip(string providerName, string parentPath, Stream compressedStream, bool recreateDirStructure, bool overwrite) { Verify.ArgumentNotNullOrEmpty(providerName, nameof(providerName)); Verify.ArgumentNotNullOrEmpty(parentPath, nameof(parentPath)); IList <IMediaFile> files; IList <IMediaFileFolder> folders; Extract(parentPath, compressedStream, out folders, out files); if (recreateDirStructure) { var folderComparer = new FolderComparer(); var currentDirs = DataFacade.GetData <IMediaFileFolder>().Where(x => x.Path.StartsWith(parentPath)); folders = folders.Except(currentDirs, folderComparer).ToList(); DataFacade.AddNew <IMediaFileFolder>(folders, providerName); AddFiles(providerName, files, overwrite); } else { foreach (IMediaFile file in files) { file.FolderPath = parentPath; } AddFiles(providerName, files, overwrite); } }
/// <exclude /> public static List <KeyValuePair> GetLocalization(string providerName) { Verify.ArgumentNotNullOrEmpty(providerName, "providerName"); Verify.ArgumentCondition(!providerName.Contains(','), "providerName", "providerName may not contain ','"); if (providerName == "XmlStringResourceProvider") { providerName = "Composite.Management"; } IDictionary <string, string> translations = ResourceProviderPluginFacade.GetAllStrings(providerName); if (translations == null) { Log.LogVerbose(LogTitle, "Missing localization section: '{0}'".FormatWith(providerName)); return(new List <KeyValuePair>()); } List <KeyValuePair> result = new List <KeyValuePair>(); foreach (KeyValuePair <string, string> pair in translations) { result.Add(new KeyValuePair(pair.Key, pair.Value)); } return(result); }
/// <exclude /> public object GetParameterValue(string parameterName, Type targetType) { Verify.ArgumentNotNullOrEmpty(parameterName, "parameterName"); if (_parameterList != null) { return(_parameterList.GetParameter(parameterName, targetType)); } if (_parameterDictionary != null) { Verify.That(_parameterDictionary.ContainsKey(parameterName), "Parameter '{0}' hasn't been defined.", parameterName); object value = _parameterDictionary[parameterName]; if (value != null && !targetType.IsInstanceOfType(value)) { return(ValueTypeConverter.Convert(value, targetType)); } return(value); } throw new InvalidOperationException("Unable to get parameter values. This context has been constructed without parameters."); }
public static IDictionary <string, string> GetAllStrings(string section) { Verify.ArgumentNotNullOrEmpty(section, "section"); var currentCulture = Thread.CurrentThread.CurrentUICulture; IDictionary <string, string> result = null; foreach (var localizationProvider in GetLocalizationProviders()) { var strings = localizationProvider.GetAllStrings(section, currentCulture); if (strings == null) { continue; } result = result ?? new Dictionary <string, string>(); foreach (var kvp in strings) { if (!result.ContainsKey(kvp.Key)) { result.Add(kvp.Key, ReplaceReferences(kvp.Value)); } } } return(result); }
private Type GetType(string fullName, bool throwIfNotFound) { Verify.ArgumentNotNullOrEmpty(fullName, "fullName"); Type type; // A little nasty check here... /MRJ if (fullName.StartsWith("<t")) { var element = XElement.Parse(fullName); type = GetGenericType(element); } else { type = GetNonGenericType(fullName); } if (throwIfNotFound && type == null) { throw new InvalidOperationException($"The type '{fullName}' could not be found"); } return(type); }
public void DeleteResource(string key) { Verify.ArgumentNotNullOrEmpty(key, nameof(key)); using (var transaction = TransactionsFacade.CreateNewScope()) { using (var data = new DataConnection()) { var resourceKey = data.Get <IResourceKey>().SingleOrDefault(r => Equals(r.ResourceSet, _resourceSet) && r.Key == key); if (resourceKey != null) { var resourceValue = data.Get <IResourceValue>().SingleOrDefault(r => r.KeyId == resourceKey.Id && r.Culture == _cultureName); if (resourceValue != null) { data.Delete(resourceValue); } if (!data.Get <IResourceValue>().Any(v => v.KeyId == resourceKey.Id)) { data.Delete(resourceKey); } } } transaction.Complete(); } }
private static void StoreUsernameImpl(string userName, bool persistAcrossSessions) { Verify.ArgumentNotNullOrEmpty(userName, "userName"); userName = userName.ToLower(CultureInfo.InvariantCulture); TimeSpan timeToLive = (persistAcrossSessions ? TimeSpan.FromDays(365) : TempTicketMaxAge); var ticket = new FormsAuthenticationTicket(userName, persistAcrossSessions, (int)timeToLive.TotalMinutes); string encryptedTicket = FormsAuthentication.Encrypt(ticket); var cookie = CookieHandler.SetCookieInternal(AuthCookieName, encryptedTicket); cookie.HttpOnly = true; var context = HttpContext.Current; if (context != null && context.Request.IsSecureConnection) { cookie.Secure = true; } if (persistAcrossSessions) { cookie.Expires = DateTime.Now + timeToLive; } }
public void AddResource(string key, object value) { Verify.ArgumentNotNullOrEmpty(key, nameof(key)); Verify.ArgumentNotNull(value, nameof(value)); using (var transaction = TransactionsFacade.CreateNewScope()) { using (var data = new DataConnection()) { var resourceKey = data.Get <IResourceKey>().SingleOrDefault(k => Equals(k.ResourceSet, _resourceSet) && k.Key == key); if (resourceKey == null) { resourceKey = data.CreateNew <IResourceKey>(); resourceKey.Id = Guid.NewGuid(); resourceKey.Key = key; resourceKey.ResourceSet = _resourceSet; data.Add(resourceKey); } var resourceValue = data.CreateNew <IResourceValue>(); resourceValue.Id = Guid.NewGuid(); resourceValue.KeyId = resourceKey.Id; resourceValue.Culture = _cultureName; resourceValue.Value = value.ToString(); data.Add(resourceValue); } transaction.Complete(); } }
public static string Encrypt(string value) { Verify.ArgumentNotNullOrEmpty(value, nameof(value)); // Create a RijndaelManaged object // with the specified key and IV. using (var rima = new RijndaelManaged()) { rima.Key = _encryptionKey; rima.IV = RijndaelIV; // Create a decrytor to perform the stream transform. ICryptoTransform encryptor = rima.CreateEncryptor(); // Create the streams used for encryption. using (var msEncrypt = new MemoryStream()) { using (var csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write)) using (var swEncrypt = new C1StreamWriter(csEncrypt)) { //Write all data to the stream. swEncrypt.Write(value); } // Return the encrypted bytes from the memory stream. return(ByteToHexString(msEncrypt.ToArray())); } } }
/// <summary> /// Builds an instance of <see cref="SearchDocument"/> based on collected information. /// </summary> /// <param name="source">The document source name</param> /// <param name="documentId">The document id</param> /// <param name="label">The label of the item in the tree</param> /// <param name="versionName">The version name of the item</param> /// <param name="entityToken">The entity token.</param> /// <returns></returns> public SearchDocument BuildDocument( string source, string documentId, string label, string versionName, EntityToken entityToken) { Verify.ArgumentNotNullOrEmpty(source, nameof(source)); Verify.ArgumentNotNullOrEmpty(documentId, nameof(documentId)); Verify.ArgumentNotNullOrEmpty(label, nameof(label)); _fieldValues.Add(new KeyValuePair <string, object>(DocumentFieldNames.Label, label)); if (!string.IsNullOrWhiteSpace(Url)) { _facetFieldValues.Add(new KeyValuePair <string, string[]>(DocumentFieldNames.HasUrl, new[] { "1" })); } AddAccessField(entityToken); return(new SearchDocument(source, documentId, label, entityToken) { ElementBundleName = versionName, FullText = _textParts, Url = Url, FieldValues = _fieldValues .ExcludeDuplicateKeys(pair => pair.Key) .ToDictionary(pair => pair.Key, pair => pair.Value), FacetFieldValues = _facetFieldValues .ExcludeDuplicateKeys(pair => pair.Key) .ToDictionary(pair => pair.Key, pair => pair.Value) }); }
public ZipFileSystem(string zipFilename) { Verify.ArgumentNotNullOrEmpty(zipFilename, "zipFilename"); ZipFilename = zipFilename; Initialize(); }
internal SqlDataProviderStoreManipulator(string connectionString, IEnumerable <InterfaceConfigurationElement> generatedInterfaces) { Verify.ArgumentNotNullOrEmpty(connectionString, "connectionString"); Verify.ArgumentNotNull(generatedInterfaces, "generatedInterfaces"); _connectionString = connectionString; _generatedInterfaces = generatedInterfaces; }
public static IEnumerable <Element> GetRoots(string providerName, SearchToken seachToken) { Verify.ArgumentNotNullOrEmpty(providerName, nameof(providerName)); IEnumerable <Element> roots = GetElementProvider(providerName).GetRoots(seachToken); return(roots ?? Enumerable.Empty <Element>()); }
public static IEnumerable <ElementAction> GetActions(string providerName, EntityToken entityToken) { Verify.ArgumentNotNullOrEmpty(providerName, "providerName"); IElementActionProvider elementActionProvider = GetElementActionProvider(providerName); return(elementActionProvider.GetActions(entityToken)); }
/// <exclude /> public void SetNewTypeFullName(string typeName, string typeNamespace) { Verify.ArgumentNotNullOrEmpty(typeName, "typeName"); Verify.ArgumentNotNullOrEmpty(typeNamespace, "typeNamespace"); _newTypeName = typeName; _newTypeNamespace = typeNamespace; }
public Type GetType(string providerName, string fullName) { Verify.ArgumentNotNullOrEmpty(providerName, "providerName"); Verify.ArgumentNotNullOrEmpty(fullName, "fullName"); ITypeManagerTypeHandler typeManagerTypeHandler = GetTypeManagerTypeHandler(providerName); return(typeManagerTypeHandler.GetType(fullName)); }
public bool HasTypeWithName(string providerName, string typeFullname) { Verify.ArgumentNotNullOrEmpty(providerName, "providerName"); Verify.ArgumentNotNullOrEmpty(typeFullname, "typeFullname"); ITypeManagerTypeHandler typeManagerTypeHandler = GetTypeManagerTypeHandler(providerName); return(typeManagerTypeHandler.HasTypeWithName(typeFullname)); }
public static string Encrypt(string value) { Verify.ArgumentNotNullOrEmpty(value, "value"); // Declare the streams used // to encrypt to an in memory // array of bytes. MemoryStream msEncrypt = null; CryptoStream csEncrypt = null; C1StreamWriter swEncrypt = null; // Declare the RijndaelManaged object // used to encrypt the data. RijndaelManaged rima = null; try { // Create a RijndaelManaged object // with the specified key and IV. rima = new RijndaelManaged(); rima.Key = _encryptionKey; rima.IV = RijndaelIV; // Create a decrytor to perform the stream transform. ICryptoTransform encryptor = rima.CreateEncryptor(); // Create the streams used for encryption. msEncrypt = new MemoryStream(); csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write); swEncrypt = new C1StreamWriter(csEncrypt); //Write all data to the stream. swEncrypt.Write(value); } finally { if (swEncrypt != null) { swEncrypt.Close(); } if (csEncrypt != null) { csEncrypt.Close(); } if (msEncrypt != null) { msEncrypt.Close(); } if (rima != null) { rima.Clear(); } } // Return the encrypted bytes from the memory stream. return(ByteToHexString(msEncrypt.ToArray())); }
/// <summary> /// Constructs a search query. /// </summary> public SearchQuery(string query, CultureInfo cultureInfo) { Verify.ArgumentNotNullOrEmpty(query, nameof(query)); Verify.ArgumentNotNull(cultureInfo, nameof(cultureInfo)); Query = query; CultureInfo = cultureInfo; MaxDocumentsNumber = 100; }
public string SerializedType(string providerName, Type type) { Verify.ArgumentNotNullOrEmpty(providerName, "providerName"); Verify.ArgumentNotNull(type, "type"); ITypeManagerTypeHandler typeManagerTypeHandler = GetTypeManagerTypeHandler(providerName); return(typeManagerTypeHandler.SerializeType(type)); }
public static IEnumerable <Element> GetChildren(string providerName, EntityToken entityToken, SearchToken seachToken) { Verify.ArgumentNotNullOrEmpty(providerName, nameof(providerName)); Verify.ArgumentNotNull(entityToken, nameof(entityToken)); IEnumerable <Element> children = GetElementProvider(providerName).GetChildren(entityToken, seachToken); return(children ?? Enumerable.Empty <Element>()); }