当前位置: 首页>>代码示例>>C#>>正文


C# Realm类代码示例

本文整理汇总了C#中Realm的典型用法代码示例。如果您正苦于以下问题:C# Realm类的具体用法?C# Realm怎么用?C# Realm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Realm类属于命名空间,在下文中一共展示了Realm类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: parameterizedProgrammaticOPIdentifierTest

		void parameterizedProgrammaticOPIdentifierTest(Identifier opIdentifier, ProtocolVersion version,
			Identifier claimedUrl, AuthenticationRequestMode requestMode,
			AuthenticationStatus expectedResult, bool provideStore) {

			var rp = TestSupport.CreateRelyingParty(provideStore ? TestSupport.RelyingPartyStore : null, null, null);

			var returnTo = TestSupport.GetFullUrl(TestSupport.ConsumerPage);
			var realm = new Realm(TestSupport.GetFullUrl(TestSupport.ConsumerPage).AbsoluteUri);
			var request = rp.CreateRequest(opIdentifier, realm, returnTo);
			request.Mode = requestMode;

			var rpResponse = TestSupport.CreateRelyingPartyResponseThroughProvider(request,
				opReq => {
					opReq.IsAuthenticated = expectedResult == AuthenticationStatus.Authenticated;
					if (opReq.IsAuthenticated.Value) {
						opReq.ClaimedIdentifier = claimedUrl;
					}
				});
			Assert.AreEqual(expectedResult, rpResponse.Status);
			if (rpResponse.Status == AuthenticationStatus.Authenticated) {
				Assert.AreEqual(claimedUrl, rpResponse.ClaimedIdentifier);
			} else if (rpResponse.Status == AuthenticationStatus.SetupRequired) {
				Assert.IsNull(rpResponse.ClaimedIdentifier);
				Assert.IsNull(rpResponse.FriendlyIdentifierForDisplay);
				Assert.IsNull(rpResponse.Exception);
				Assert.IsInstanceOfType(typeof(ISetupRequiredAuthenticationResponse), rpResponse);
				Assert.AreEqual(opIdentifier.ToString(), ((ISetupRequiredAuthenticationResponse)rpResponse).ClaimedOrProviderIdentifier.ToString());
			}
		}
开发者ID:Belxjander,项目名称:Asuna,代码行数:29,代码来源:EndToEndTesting.cs

示例2: NotImplementedException

        /// <summary>
        /// Gets the Identifier to use for the Claimed Identifier and Local Identifier of
        /// an outgoing positive assertion.
        /// </summary>
        /// <param name="localIdentifier">The OP local identifier for the authenticating user.</param>
        /// <param name="relyingPartyRealm">The realm of the relying party receiving the assertion.</param>
        /// <returns>
        /// A valid, discoverable OpenID Identifier that should be used as the value for the
        /// openid.claimed_id and openid.local_id parameters.  Must not be null.
        /// </returns>
        Uri IDirectedIdentityIdentifierProvider.GetIdentifier(Identifier localIdentifier, Realm relyingPartyRealm)
        {
            Contract.Requires(localIdentifier != null);
            Contract.Requires(relyingPartyRealm != null);

            throw new NotImplementedException();
        }
开发者ID:jcp-xx,项目名称:dotnetopenid,代码行数:17,代码来源:IDirectedIdentityIdentifierProvider.cs

示例3: onCreate

		protected internal override void onCreate(Bundle savedInstanceState)
		{
			base.onCreate(savedInstanceState);

			// Generate a key
			// IMPORTANT! This is a silly way to generate a key. It is also never stored.
			// For proper key handling please consult:
			// * https://developer.android.com/training/articles/keystore.html
			// * http://nelenkov.blogspot.dk/2012/05/storing-application-secrets-in-androids.html
			sbyte[] key = new sbyte[64];
			(new SecureRandom()).NextBytes(key);
			RealmConfiguration realmConfiguration = (new RealmConfiguration.Builder(this)).encryptionKey(key).build();

			// Start with a clean slate every time
			Realm.deleteRealm(realmConfiguration);

			// Open the Realm with encryption enabled
			realm = Realm.getInstance(realmConfiguration);

			// Everything continues to work as normal except for that the file is encrypted on disk
			realm.beginTransaction();
			Person person = realm.createObject(typeof(Person));
			person.Name = "Happy Person";
			person.Age = 14;
			realm.commitTransaction();

			person = [email protected](typeof(Person)).findFirst();
			Log.i(TAG, string.Format("Person name: {0}", person.Name));
		}
开发者ID:moljac,项目名称:Samples.Data.Porting,代码行数:29,代码来源:EncryptionExampleActivity.cs

示例4: CreateCharacter

        public static void CreateCharacter(Realm.Characters.Character character)
        {
            lock (DatabaseHandler.ConnectionLocker)
            {
                var sqlText = "INSERT INTO dyn_characters VALUES(@id, @name, @level, @class, @sex, @color, @color2, @color3, @mapinfos, @stats, @items, @spells, @exp)";
                var sqlCommand = new MySqlCommand(sqlText, DatabaseHandler.Connection);

                var P = sqlCommand.Parameters;

                P.Add(new MySqlParameter("@id", character.ID));
                P.Add(new MySqlParameter("@name", character.Name));
                P.Add(new MySqlParameter("@level", character.Level));
                P.Add(new MySqlParameter("@class", character.Class));
                P.Add(new MySqlParameter("@sex", character.Sex));
                P.Add(new MySqlParameter("@color", character.Color));
                P.Add(new MySqlParameter("@color2", character.Color2));
                P.Add(new MySqlParameter("@color3", character.Color3));
                P.Add(new MySqlParameter("@mapinfos", character.MapID + "," + character.MapCell + "," + character.Dir));
                P.Add(new MySqlParameter("@stats", character.SqlStats()));
                P.Add(new MySqlParameter("@items", ""));
                P.Add(new MySqlParameter("@spells", ""));
                P.Add(new MySqlParameter("@exp", 0));

                sqlCommand.ExecuteNonQuery();

                character.isNewCharacter = false;
            }
        }
开发者ID:T4NK,项目名称:SunDofus,代码行数:28,代码来源:CharactersCache.cs

示例5: ImplicitConversionToStringTests

 public void ImplicitConversionToStringTests()
 {
     Realm realm = new Realm("http://host/");
     string realmString = realm;
     Assert.AreEqual("http://host/", realmString);
     realm = null;
     realmString = realm;
     Assert.IsNull(realmString);
 }
开发者ID:tt,项目名称:dotnetopenid,代码行数:9,代码来源:RealmTestSuite.cs

示例6: onStart

		public override void onStart()
		{
			base.onStart();
			// Create Realm instance for the UI thread
			realm = Realm.DefaultInstance;
			allSortedDots = [email protected](typeof(Dot)).between("x", 25, 75).between("y", 0, 50).findAllSortedAsync("x", RealmResults.SORT_ORDER_ASCENDING, "y", RealmResults.SORT_ORDER_DESCENDING);
			dotAdapter.updateList(allSortedDots);
			allSortedDots.addChangeListener(this);
		}
开发者ID:moljac,项目名称:Samples.Data.Porting,代码行数:9,代码来源:AsyncQueryFragment.cs

示例7: JournalEntriesViewModel

        public JournalEntriesViewModel()
        {
            _realm = Realm.GetInstance();

            Entries = _realm.All<JournalEntry>();

            AddEntryCommand = new Command(AddEntry);
            DeleteEntryCommand = new Command<JournalEntry>(DeleteEntry);
        }
开发者ID:realm,项目名称:realm-dotnet,代码行数:9,代码来源:JournalEntriesViewModel.cs

示例8: onCreate

		protected internal override void onCreate(Bundle savedInstanceState)
		{
			base.onCreate(savedInstanceState);
			ContentView = R.layout.activity_realm_example;

			RealmConfiguration realmConfiguration = (new RealmConfiguration.Builder(this)).build();
			Realm.deleteRealm(realmConfiguration);
			realm = Realm.getInstance(realmConfiguration);
		}
开发者ID:moljac,项目名称:Samples.Data.Porting,代码行数:9,代码来源:JsonExampleActivity.cs

示例9: CreateRequestsAsync

		/// <summary>
		/// Generates AJAX-ready authentication requests that can satisfy the requirements of some OpenID Identifier.
		/// </summary>
		/// <param name="userSuppliedIdentifier">The Identifier supplied by the user.  This may be a URL, an XRI or i-name.</param>
		/// <param name="realm">The shorest URL that describes this relying party web site's address.
		/// For example, if your login page is found at https://www.example.com/login.aspx,
		/// your realm would typically be https://www.example.com/.</param>
		/// <param name="returnToUrl">The URL of the login page, or the page prepared to receive authentication
		/// responses from the OpenID Provider.</param>
		/// <param name="cancellationToken">The cancellation token.</param>
		/// <returns>
		/// A sequence of authentication requests, any of which constitutes a valid identity assertion on the Claimed Identifier.
		/// Never null, but may be empty.
		/// </returns>
		/// <remarks>
		///   <para>Any individual generated request can satisfy the authentication.
		/// The generated requests are sorted in preferred order.
		/// Each request is generated as it is enumerated to.  Associations are created only as
		///   <see cref="IAuthenticationRequest.GetRedirectingResponseAsync" /> is called.</para>
		///   <para>No exception is thrown if no OpenID endpoints were discovered.
		/// An empty enumerable is returned instead.</para>
		/// </remarks>
		public override async Task<IEnumerable<IAuthenticationRequest>> CreateRequestsAsync(Identifier userSuppliedIdentifier, Realm realm, Uri returnToUrl, CancellationToken cancellationToken) {
			var requests = await base.CreateRequestsAsync(userSuppliedIdentifier, realm, returnToUrl, cancellationToken);
			var results = new List<IAuthenticationRequest>();

			// Alter the requests so that have AJAX characteristics.
			// Some OPs may be listed multiple times (one with HTTPS and the other with HTTP, for example).
			// Since we're gathering OPs to try one after the other, just take the first choice of each OP
			// and don't try it multiple times.
			requests = requests.Distinct(DuplicateRequestedHostsComparer.Instance);

			// Configure each generated request.
			int reqIndex = 0;
			foreach (var req in requests) {
				// Inform ourselves in return_to that we're in a popup.
				req.SetUntrustedCallbackArgument(OpenIdRelyingPartyControlBase.UIPopupCallbackKey, "1");

				if (req.DiscoveryResult.IsExtensionSupported<UIRequest>()) {
					// Inform the OP that we'll be using a popup window consistent with the UI extension.
					req.AddExtension(new UIRequest());

					// Provide a hint for the client javascript about whether the OP supports the UI extension.
					// This is so the window can be made the correct size for the extension.
					// If the OP doesn't advertise support for the extension, the javascript will use
					// a bigger popup window.
					req.SetUntrustedCallbackArgument(OpenIdRelyingPartyControlBase.PopupUISupportedJSHint, "1");
				}

				req.SetUntrustedCallbackArgument("index", (reqIndex++).ToString(CultureInfo.InvariantCulture));

				// If the ReturnToUrl was explicitly set, we'll need to reset our first parameter
				if (OpenIdElement.Configuration.RelyingParty.PreserveUserSuppliedIdentifier) {
					if (string.IsNullOrEmpty(HttpUtility.ParseQueryString(req.ReturnToUrl.Query)[AuthenticationRequest.UserSuppliedIdentifierParameterName])) {
						req.SetUntrustedCallbackArgument(AuthenticationRequest.UserSuppliedIdentifierParameterName, userSuppliedIdentifier.OriginalString);
					}
				}

				// Our javascript needs to let the user know which endpoint responded.  So we force it here.
				// This gives us the info even for 1.0 OPs and 2.0 setup_required responses.
				req.SetUntrustedCallbackArgument(OpenIdRelyingPartyAjaxControlBase.OPEndpointParameterName, req.Provider.Uri.AbsoluteUri);
				req.SetUntrustedCallbackArgument(OpenIdRelyingPartyAjaxControlBase.ClaimedIdParameterName, (string)req.ClaimedIdentifier ?? string.Empty);

				// Inform ourselves in return_to that we're in a popup or iframe.
				req.SetUntrustedCallbackArgument(OpenIdRelyingPartyAjaxControlBase.UIPopupCallbackKey, "1");

				// We append a # at the end so that if the OP happens to support it,
				// the OpenID response "query string" is appended after the hash rather than before, resulting in the
				// browser being super-speedy in closing the popup window since it doesn't try to pull a newer version
				// of the static resource down from the server merely because of a changed URL.
				// http://www.nabble.com/Re:-Defining-how-OpenID-should-behave-with-fragments-in-the-return_to-url-p22694227.html
				////TODO:

				results.Add(req);
			}

			return results;
		}
开发者ID:Adilson,项目名称:dotnetopenid,代码行数:78,代码来源:OpenIdAjaxRelyingParty.cs

示例10: GetHero

		public void GetHero(Realm realm, string battleTag, uint heroId, Action<Hero> callback)
		{
			string uri = string.Format(heroUri, App.GetDomain(realm), battleTag, heroId);
			Action<string> action = delegate(string json)
			{
				var hero = JsonConvert.DeserializeObject<Hero>(json);
				callback(hero);
			};
			this.SendRequest(uri, action);
		}
开发者ID:cuteribs,项目名称:Cuteribs.D3Armory,代码行数:10,代码来源:D3Client.cs

示例11: GetProfile

		public void GetProfile(Realm realm, string battleTag, Action<Profile> callback)
		{
			string uri = string.Format(profileUri, App.GetDomain(realm), battleTag);
			Action<string> action = delegate(string json)
			{
				var profile = JsonConvert.DeserializeObject<Profile>(json);
				profile.Realm = realm;
				callback(profile);
			};
			this.SendRequest(uri, action);
		}
开发者ID:cuteribs,项目名称:Cuteribs.D3Armory,代码行数:11,代码来源:D3Client.cs

示例12: GetRelyingPartyIconUrlsAsync

		/// <summary>
		/// Gets the URL of the RP icon for the OP to display.
		/// </summary>
		/// <param name="realm">The realm of the RP where the authentication request originated.</param>
		/// <param name="hostFactories">The host factories.</param>
		/// <param name="cancellationToken">The cancellation token.</param>
		/// <returns>
		/// A sequence of the RP's icons it has available for the Provider to display, in decreasing preferred order.
		/// </returns>
		/// <value>The icon URL.</value>
		/// <remarks>
		/// This property is automatically set for the OP with the result of RP discovery.
		/// RPs should set this value by including an entry such as this in their XRDS document.
		/// <example>
		/// &lt;Service xmlns="xri://$xrd*($v*2.0)"&gt;
		/// &lt;Type&gt;http://specs.openid.net/extensions/ui/icon&lt;/Type&gt;
		/// &lt;URI&gt;http://consumer.example.com/images/image.jpg&lt;/URI&gt;
		/// &lt;/Service&gt;
		/// </example>
		/// </remarks>
		public static async Task<IEnumerable<Uri>> GetRelyingPartyIconUrlsAsync(Realm realm, IHostFactories hostFactories, CancellationToken cancellationToken) {
			Requires.NotNull(realm, "realm");
			Requires.NotNull(hostFactories, "hostFactories");

			XrdsDocument xrds = await realm.DiscoverAsync(hostFactories, false, cancellationToken);
			if (xrds == null) {
				return Enumerable.Empty<Uri>();
			} else {
				return xrds.FindRelyingPartyIcons();
			}
		}
开发者ID:Balamir,项目名称:DotNetOpenAuth,代码行数:31,代码来源:UIRequestTools.cs

示例13: HasConditions

        public bool HasConditions(Realm.Characters.Character _character)
        {
            foreach (var condi in Conditions)
            {
                if (condi.HasCondition(_character))
                    continue;
                else
                    return false;
            }

            return true;
        }
开发者ID:T4NK,项目名称:SunDofus,代码行数:12,代码来源:NPCsQuestion.cs

示例14: Apply

 internal void Apply(Realm Realm)
 {
     Vector3i BlockCoords = ChunkCoords * Size;
     for (int x = 0; x < Size.X; x++) {
         for (int y = 0; y < Size.Y; y++) {
             for (int z = 0; z < Size.Z; z++) {
                 Vector3i BlockAt = BlockCoords + new Vector3i(x, y, z);
                 Realm.SetBlock(BlockAt, BlockData[x, y, z]);
             }
         }
     }
 }
开发者ID:CloneDeath,项目名称:FantasyScape,代码行数:12,代码来源:NetworkChunk.cs

示例15: ApplyEffects

 public void ApplyEffects(Realm.Characters.Character character)
 {
     try
     {
         foreach (var effect in Effects.Split('|'))
         {
             var infos = effect.Split(';');
             Realm.Effects.EffectAction.ParseEffect(character, int.Parse(infos[0]), infos[1]);
         }
     }
     catch { }
 }
开发者ID:T4NK,项目名称:SunDofus,代码行数:12,代码来源:NPCsAnswer.cs


注:本文中的Realm类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。