/// <summary> /// Creates a cache key for the macro's parameters and cache options. /// </summary> /// <param name="macroParams">A dicitonary of the parameters</param> /// <param name="currentPageId">The current page hiveId. If null, CacheByPage is false.</param> /// <param name="currentMemberId">The current member hiveId. If null, CachePersonalized is false.</param> /// <returns>A repeatable string key that represents the macro settings</returns> private static string GetMacroCacheKey(string macroAlias, IDictionary <string, string> macroParams, HiveId?currentPageId, HiveId?currentMemberId) { // hold the string while we build it up. var keyBuilder = new StringBuilder(); keyBuilder.Append(MacroCachePrefix); keyBuilder.Append(macroAlias.ToUpperInvariant()); keyBuilder.Append("-"); // cache by page and member are added to the key FIRST // so that it is easier to debug/view. // cache by page? if (currentPageId.HasValue && currentPageId.Value != HiveId.Empty) { var cacheByPageId = currentPageId.Value; // if the macroParams contains this item, that means the user is // overriding the requested item for the specified page. var userCurrentPageOverride = macroParams.GetEntryIgnoreCase(MacroPageParameterKey); if (!userCurrentPageOverride.IsNullOrWhiteSpace()) { var parsed = HiveId.TryParse(userCurrentPageOverride); if (parsed.Success && parsed.Result != HiveId.Empty) { cacheByPageId = parsed.Result; } } // add it to the key AppendMacroParam(keyBuilder, MacroPageParameterKey, cacheByPageId); } // personalized by member? if (currentMemberId.HasValue) { var cacheByMemberId = currentMemberId.Value; // if macroParams contains this item, we override it with the developer supplied value. var developerMemberOverride = macroParams.GetEntryIgnoreCase(MacroMemberParameterKey); if (!developerMemberOverride.IsNullOrWhiteSpace()) { var parsed = HiveId.TryParse(developerMemberOverride); if (parsed.Success) { cacheByMemberId = parsed.Result; } } // add it to the key AppendMacroParam(keyBuilder, MacroMemberParameterKey, cacheByMemberId); } // now add all of the macro parameters to the key! macroParams.OrderBy(kvp => kvp.Key).ForEach(kvp => AppendMacroParam(keyBuilder, kvp.Key, kvp.Value)); // return the stringed key! return(keyBuilder.ToString()); }
private static bool IsMastStream(IDictionary <string, string> streamAttributes) { StreamType result; string type = streamAttributes.GetEntryIgnoreCase(TypeAttribute); string subType = streamAttributes.GetEntryIgnoreCase(SubTypeAttribute); return(type.EnumTryParse(true, out result) && result == StreamType.Text && AllowedStreamSubTypes.Any(i => string.Equals(i, subType, StringComparison.CurrentCultureIgnoreCase))); }
private static bool IsCaptionStream(IDictionary <string, string> streamAttributes) { StreamType result; string type = streamAttributes.GetEntryIgnoreCase(TypeAttribute); string subType = streamAttributes.GetEntryIgnoreCase(SubTypeAttribute); #if SILVERLIGHT3 return(SystemExtensions.TryParse(type, true, out result) #else return Enum.TryParse(type, true, out result) #endif && result == StreamType.Text && AllowedCaptionStreamSubTypes.Any(i => string.Equals(i, subType, StringComparison.CurrentCultureIgnoreCase))); }
public static bool CompareMetadata(this MetadataCollection requirements, IDictionary <string, object> provided) { bool result = requirements.All( i => provided.ContainsKeyIgnoreCase(i.Key) && CompareMetadataItems(i.Value, provided.GetEntryIgnoreCase(i.Key))); return(result); }
public static bool TryGetPlayerXamlThemeSource(IDictionary<string, string> initParams, out Uri xamlThemeSource) { if (initParams.ContainsKeyIgnoreCase("XamlThemeSource")) { if (Uri.TryCreate(initParams.GetEntryIgnoreCase("XamlThemeSource"), UriKind.RelativeOrAbsolute, out xamlThemeSource)) { return true; } } xamlThemeSource = null; return false; }
private static bool TryGetPlayerSettings(IDictionary<string, string> initParams, out IPlayerSettings playerSettings) { if (initParams.ContainsKeyIgnoreCase("InitialSettings")) { string xmlSettings = initParams.GetEntryIgnoreCase("InitialSettings"); if (!String.IsNullOrWhiteSpace(xmlSettings)) { var serializer = new XmlSerializer(typeof(PlayerSettings)); playerSettings = (IPlayerSettings)serializer.Deserialize(xmlSettings.AsStream()); return true; } } playerSettings = null; return false; }
/// <summary>The get entry ignore case.</summary> /// <param name="dictionary">The dictionary.</param> /// <param name="key">The key.</param> /// <typeparam name="TValue">The type</typeparam> /// <returns>The entry</returns> public static TValue GetEntryIgnoreCase <TValue>(this IDictionary <string, TValue> dictionary, string key) { return(dictionary.GetEntryIgnoreCase(key, default(TValue))); }
private static bool IsMastStream(IDictionary<string, string> streamAttributes) { StreamType result; string type = streamAttributes.GetEntryIgnoreCase(TypeAttribute); string subType = streamAttributes.GetEntryIgnoreCase(SubTypeAttribute); return type.EnumTryParse(true, out result) && result == StreamType.Text && AllowedStreamSubTypes.Any(i => string.Equals(i, subType, StringComparison.CurrentCultureIgnoreCase)); }
/// <summary> /// Load settings from init params /// </summary> /// <param name="initParams"></param> public void LoadInitParams(IDictionary<string, string> initParams) { bool autoPlay; FeatureVisibility playerGraphVisibility; if (initParams.ContainsKeyIgnoreCase(SupportedInitParams.Title)) { MediaTitleContent = initParams.GetEntryIgnoreCase(SupportedInitParams.Title); } if (initParams.ContainsKeyIgnoreCase(SupportedInitParams.ScriptableName) && !initParams.GetEntryIgnoreCase(SupportedInitParams.ScriptableName).IsNullOrWhiteSpace()) { ScriptableName = initParams.GetEntryIgnoreCase(SupportedInitParams.ScriptableName); } if (initParams.ContainsKeyIgnoreCase(SupportedInitParams.AutoPlay) && bool.TryParse(initParams.GetEntryIgnoreCase(SupportedInitParams.AutoPlay), out autoPlay)) { AutoPlay = autoPlay; } if (initParams.ContainsKeyIgnoreCase(SupportedInitParams.PlayerGraphVisibility) && FeatureVisibility.TryParse(initParams.GetEntryIgnoreCase(SupportedInitParams.PlayerGraphVisibility), true, out playerGraphVisibility)) { PlayerGraphVisibility = playerGraphVisibility; } bool isStartPositionOffset = true; if (initParams.ContainsKeyIgnoreCase(SupportedInitParams.IsStartPositionOffset) && bool.TryParse(initParams.GetEntryIgnoreCase(SupportedInitParams.IsStartPositionOffset), out isStartPositionOffset)) { IsStartPositionOffset = isStartPositionOffset; } if (initParams.ContainsKeyIgnoreCase(SupportedInitParams.MediaUrl) && !initParams.GetEntryIgnoreCase(SupportedInitParams.MediaUrl).IsNullOrWhiteSpace()) { var playlist = new ObservableCollection<PlaylistItem>(); var playlistItem = new PlaylistItem { MediaSource = new Uri(initParams.GetEntryIgnoreCase(SupportedInitParams.MediaUrl)) }; DeliveryMethods deliveryMethod; if (initParams.ContainsKeyIgnoreCase(SupportedInitParams.DeliveryMethod) && initParams.GetEntryIgnoreCase(SupportedInitParams.DeliveryMethod).EnumTryParse(true, out deliveryMethod)) { playlistItem.DeliveryMethod = deliveryMethod; } if (initParams.ContainsKeyIgnoreCase(SupportedInitParams.SelectedCaptionStream) && !initParams.GetEntryIgnoreCase(SupportedInitParams.SelectedCaptionStream).IsNullOrWhiteSpace()) { playlistItem.SelectedCaptionStreamName = initParams.GetEntryIgnoreCase(SupportedInitParams.SelectedCaptionStream); } if (initParams.ContainsKeyIgnoreCase(SupportedInitParams.ThumbnailUrl) && !initParams.GetEntryIgnoreCase(SupportedInitParams.ThumbnailUrl).IsNullOrWhiteSpace()) { playlistItem.ThumbSource = new Uri(initParams.GetEntryIgnoreCase(SupportedInitParams.ThumbnailUrl)); } playlist.Add(playlistItem); Playlist = playlist; } else if (initParams.ContainsKeyIgnoreCase(SupportedInitParams.PlayerSettings) && !initParams.GetEntryIgnoreCase(SupportedInitParams.PlayerSettings).IsNullOrWhiteSpace()) { ImportPlayerSettings(initParams.GetEntryIgnoreCase(SupportedInitParams.PlayerSettings)); } Uri pluginSource; if (initParams.ContainsKeyIgnoreCase(SupportedInitParams.PluginUrl) && !initParams.GetEntryIgnoreCase(SupportedInitParams.PluginUrl).IsNullOrWhiteSpace() && Uri.TryCreate(initParams.GetEntryIgnoreCase(SupportedInitParams.PluginUrl), UriKind.RelativeOrAbsolute, out pluginSource)) { BeginAddExternalPlugins(pluginSource); } }
private static bool IsCaptionStream(IDictionary<string, string> streamAttributes) { StreamType result; string type = streamAttributes.GetEntryIgnoreCase(TypeAttribute); string subType = streamAttributes.GetEntryIgnoreCase(SubTypeAttribute); #if SILVERLIGHT3 return SystemExtensions.TryParse(type, true, out result) #else return Enum.TryParse(type, true, out result) #endif && result == StreamType.Text && AllowedCaptionStreamSubTypes.Any(i => string.Equals(i, subType, StringComparison.CurrentCultureIgnoreCase)); }
/// <summary> /// Creates a cache key for the macro's parameters and cache options. /// </summary> /// <param name="macroParams">A dicitonary of the parameters</param> /// <param name="currentPageId">The current page hiveId. If null, CacheByPage is false.</param> /// <param name="currentMemberId">The current member hiveId. If null, CachePersonalized is false.</param> /// <returns>A repeatable string key that represents the macro settings</returns> private static string GetMacroCacheKey(string macroAlias, IDictionary<string, string> macroParams, HiveId? currentPageId, HiveId? currentMemberId) { // hold the string while we build it up. var keyBuilder = new StringBuilder(); keyBuilder.Append(MacroCachePrefix); keyBuilder.Append(macroAlias.ToUpperInvariant()); keyBuilder.Append("-"); // cache by page and member are added to the key FIRST // so that it is easier to debug/view. // cache by page? if (currentPageId.HasValue && currentPageId.Value != HiveId.Empty) { var cacheByPageId = currentPageId.Value; // if the macroParams contains this item, that means the user is // overriding the requested item for the specified page. var userCurrentPageOverride = macroParams.GetEntryIgnoreCase(MacroPageParameterKey); if (!userCurrentPageOverride.IsNullOrWhiteSpace()) { var parsed = HiveId.TryParse(userCurrentPageOverride); if (parsed.Success && parsed.Result != HiveId.Empty) { cacheByPageId = parsed.Result; } } // add it to the key AppendMacroParam(keyBuilder, MacroPageParameterKey, cacheByPageId); } // personalized by member? if (currentMemberId.HasValue) { var cacheByMemberId = currentMemberId.Value; // if macroParams contains this item, we override it with the developer supplied value. var developerMemberOverride = macroParams.GetEntryIgnoreCase(MacroMemberParameterKey); if (!developerMemberOverride.IsNullOrWhiteSpace()) { var parsed = HiveId.TryParse(developerMemberOverride); if (parsed.Success) { cacheByMemberId = parsed.Result; } } // add it to the key AppendMacroParam(keyBuilder, MacroMemberParameterKey, cacheByMemberId); } // now add all of the macro parameters to the key! macroParams.OrderBy(kvp => kvp.Key).ForEach(kvp => AppendMacroParam(keyBuilder, kvp.Key, kvp.Value)); // return the stringed key! return keyBuilder.ToString(); }