• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Realm类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: OnAppearing

        protected override void OnAppearing()
        {
            base.OnAppearing();
            _realm = Realm.GetInstance();

            var query = _realm.All<DemoObject>().OrderByDescending(o => o.Date) as RealmResults<DemoObject>;
            listView.ItemsSource = query.ToNotifyCollectionChanged(e =>
            {
                // recover from the error - recreate the query or show message to the user
                System.Diagnostics.Debug.WriteLine(e);
            }) as IEnumerable<DemoObject>;
        }
开发者ID:realm,项目名称:realm-dotnet,代码行数:12,代码来源:MainPage.xaml.cs


示例17: EqualsTest

        public void EqualsTest()
        {
            Realm tr1a = new Realm("http://www.yahoo.com");
            Realm tr1b = new Realm("http://www.yahoo.com");
            Realm tr2 = new Realm("http://www.yahoo.com/b");
            Realm tr3 = new Realm("http://*.www.yahoo.com");

            Assert.AreEqual(tr1a, tr1b);
            Assert.AreNotEqual(tr1a, tr2);
            Assert.AreNotEqual(tr1a, null);
            Assert.AreNotEqual(tr1a, tr1a.ToString(), "Although the URLs are equal, different object types shouldn't be equal.");
            Assert.AreNotEqual(tr3, tr1a, "Wildcard difference ignored by Equals");
        }
开发者ID:tt,项目名称:dotnetopenid,代码行数:13,代码来源:RealmTestSuite.cs


示例18: GetRelyingPartyIconUrls

		/// <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="webRequestHandler">The web request handler to use for discovery.
		/// Usually available via <see cref="Channel.WebRequestHandler">OpenIdProvider.Channel.WebRequestHandler</see>.</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 IEnumerable<Uri> GetRelyingPartyIconUrls(Realm realm, IDirectWebRequestHandler webRequestHandler) {
			Requires.NotNull(realm, "realm");
			Requires.NotNull(webRequestHandler, "webRequestHandler");
			ErrorUtilities.VerifyArgumentNotNull(realm, "realm");
			ErrorUtilities.VerifyArgumentNotNull(webRequestHandler, "webRequestHandler");

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


示例19: AuthenticationRequest

		/// <summary>
		/// Initializes a new instance of the <see cref="AuthenticationRequest"/> class.
		/// </summary>
		/// <param name="discoveryResult">The endpoint that describes the OpenID Identifier and Provider that will complete the authentication.</param>
		/// <param name="realm">The realm, or root URL, of the host web site.</param>
		/// <param name="returnToUrl">The base return_to URL that the Provider should return the user to to complete authentication.  This should not include callback parameters as these should be added using the <see cref="AddCallbackArguments(string, string)"/> method.</param>
		/// <param name="relyingParty">The relying party that created this instance.</param>
		private AuthenticationRequest(IdentifierDiscoveryResult discoveryResult, Realm realm, Uri returnToUrl, OpenIdRelyingParty relyingParty) {
			Contract.Requires<ArgumentNullException>(discoveryResult != null);
			Contract.Requires<ArgumentNullException>(realm != null);
			Contract.Requires<ArgumentNullException>(returnToUrl != null);
			Contract.Requires<ArgumentNullException>(relyingParty != null);

			this.DiscoveryResult = discoveryResult;
			this.RelyingParty = relyingParty;
			this.Realm = realm;
			this.ReturnToUrl = returnToUrl;

			this.Mode = AuthenticationRequestMode.Setup;
		}
开发者ID:jongalloway,项目名称:dotnetopenid,代码行数:20,代码来源:AuthenticationRequest.cs


示例20: AuthenticationRequest

		/// <summary>
		/// Initializes a new instance of the <see cref="AuthenticationRequest"/> class.
		/// </summary>
		/// <param name="discoveryResult">The endpoint that describes the OpenID Identifier and Provider that will complete the authentication.</param>
		/// <param name="realm">The realm, or root URL, of the host web site.</param>
		/// <param name="returnToUrl">The base return_to URL that the Provider should return the user to to complete authentication.  This should not include callback parameters as these should be added using the <see cref="AddCallbackArguments(string, string)"/> method.</param>
		/// <param name="relyingParty">The relying party that created this instance.</param>
		private AuthenticationRequest(IdentifierDiscoveryResult discoveryResult, Realm realm, Uri returnToUrl, OpenIdRelyingParty relyingParty) {
			Requires.NotNull(discoveryResult, "discoveryResult");
			Requires.NotNull(realm, "realm");
			Requires.NotNull(returnToUrl, "returnToUrl");
			Requires.NotNull(relyingParty, "relyingParty");

			this.DiscoveryResult = discoveryResult;
			this.RelyingParty = relyingParty;
			this.Realm = realm;
			this.ReturnToUrl = returnToUrl;

			this.Mode = AuthenticationRequestMode.Setup;
		}
开发者ID:natuangloops,项目名称:DotNetOpenAuth,代码行数:20,代码来源:AuthenticationRequest.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# RealmPacketIn类代码示例发布时间:2022-05-24
下一篇:
C# RealTimeStylus类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap